AbpAspNetCoreModule
namespace Volo.Abp.AspNetCore;
AbpAspNetCoreModule ้้
็ฝฎไบ ABP ๅจ ASP.NET CORE ไธๆไพ็ไธไบๆๅก
[DependsOn(
typeof(AbpAuditingModule),
typeof(AbpSecurityModule),
typeof(AbpVirtualFileSystemModule),
typeof(AbpUnitOfWorkModule),
typeof(AbpHttpModule),
typeof(AbpAuthorizationModule),
typeof(AbpValidationModule),
typeof(AbpExceptionHandlingModule)
)]
public class AbpAspNetCoreModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var abpHostEnvironment = context.Services.GetSingletonInstance<IAbpHostEnvironment>();
if (abpHostEnvironment.EnvironmentName.IsNullOrWhiteSpace())
{
abpHostEnvironment.EnvironmentName =
context.Services.GetHostingEnvironment().EnvironmentName;
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAuthorization();
Configure<AbpAuditingOptions>(options =>
{
options.Contributors.Add(new AspNetCoreAuditLogContributor());
});
Configure<StaticFileOptions>(options =>
{
options.ContentTypeProvider = context.Services.
GetRequiredService<AbpFileExtensionContentTypeProvider>();
});
AddAspNetServices(context.Services);
context.Services.AddObjectAccessor<IApplicationBuilder>();
context.Services.AddAbpDynamicOptions<RequestLocalizationOptions,
AbpRequestLocalizationOptionsManager>();
}
private static void AddAspNetServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var environment = context.GetEnvironmentOrNull();
if (environment != null)
{
environment.WebRootFileProvider =
new CompositeFileProvider(
context.GetEnvironment().WebRootFileProvider,
context.ServiceProvider.GetRequiredService<IWebContentFileProvider>()
);
}
}
}
๐๐๐