mirror of https://github.com/abpframework/abp.git
16 changed files with 147 additions and 29 deletions
@ -0,0 +1,33 @@ |
|||
using System.Reflection; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.EmbeddedFiles; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc |
|||
{ |
|||
[DependsOn(typeof(AbpAspNetCoreMvcModule))] |
|||
public class AbpAspNetCoreMvcUiModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpAspNetCoreMvcUiModule>(); |
|||
|
|||
services.Configure<NavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new EmbeddedDemoMainMenuContributor()); |
|||
}); |
|||
|
|||
services.Configure<EmbeddedFileOptions>(options => |
|||
{ |
|||
options.Sources.Add( |
|||
new EmbeddedFileSet( |
|||
"/Views/", |
|||
GetType().GetTypeInfo().Assembly, |
|||
"Volo.Abp.AspNetCore.Mvc.UI.Views" |
|||
) |
|||
); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Controllers |
|||
{ |
|||
public class AbpEmbeddedDemoController : AbpController |
|||
{ |
|||
public ActionResult Index() |
|||
{ |
|||
return View(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc |
|||
{ |
|||
public class EmbeddedDemoMainMenuContributor : IMenuContributor |
|||
{ |
|||
public Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name != StandardMenus.Main) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
context.Menu |
|||
.AddItem( |
|||
new ApplicationMenuItem("EmbeddedDemo", "EmbeddedDemo", url: "/AbpEmbeddedDemo") |
|||
); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<h2>ABP Embedded Demo Page</h2> |
|||
|
|||
<p>This page's content is stored as an embedded file!</p> |
|||
@ -1,14 +1,36 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using Microsoft.AspNetCore.Mvc.Razor; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.AspNetCore.EmbeddedFiles; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc |
|||
{ |
|||
[DependsOn(typeof(AbpAspNetCoreModule))] |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreModule) |
|||
)] |
|||
public class AbpAspNetCoreMvcModule : IAbpModule |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddAssemblyOf<AbpAspNetCoreMvcModule>(); |
|||
|
|||
//Configure Razor
|
|||
services.Insert(0, |
|||
ServiceDescriptor.Singleton<IConfigureOptions<RazorViewEngineOptions>>( |
|||
new ConfigureOptions<RazorViewEngineOptions>(options => |
|||
{ |
|||
options.FileProviders.Add( |
|||
new EmbeddedResourceViewFileProvider( |
|||
services.GetSingletonInstance<IObjectAccessor<IServiceProvider>>() |
|||
) |
|||
); |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,11 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.EmbeddedFiles; |
|||
using Volo.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.EmbeddedFiles |
|||
{ |
|||
public class EmbeddedResourceViewFileProvider : EmbeddedResourceFileProvider |
|||
{ |
|||
public EmbeddedResourceViewFileProvider(IServiceProvider serviceProvider) |
|||
public EmbeddedResourceViewFileProvider(IObjectAccessor<IServiceProvider> serviceProvider) |
|||
: base(serviceProvider) |
|||
{ |
|||
} |
|||
Loading…
Reference in new issue