mirror of https://github.com/abpframework/abp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Volo.Abp.Localization;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.Security;
|
|
|
|
namespace Volo.Abp.Settings
|
|
{
|
|
[DependsOn(
|
|
typeof(AbpLocalizationAbstractionsModule),
|
|
typeof(AbpSecurityModule),
|
|
typeof(AbpMultiTenancyAbstractionsModule)
|
|
)]
|
|
public class AbpSettingsModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
AutoAddDefinitionProviders(context.Services);
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
Configure<SettingOptions>(options =>
|
|
{
|
|
options.ValueProviders.Add<DefaultValueSettingValueProvider>();
|
|
options.ValueProviders.Add<GlobalSettingValueProvider>();
|
|
options.ValueProviders.Add<TenantSettingValueProvider>();
|
|
options.ValueProviders.Add<UserSettingValueProvider>();
|
|
});
|
|
}
|
|
|
|
private static void AutoAddDefinitionProviders(IServiceCollection services)
|
|
{
|
|
var definitionProviders = new List<Type>();
|
|
|
|
services.OnRegistred(context =>
|
|
{
|
|
if (typeof(ISettingDefinitionProvider).IsAssignableFrom(context.ImplementationType))
|
|
{
|
|
definitionProviders.Add(context.ImplementationType);
|
|
}
|
|
});
|
|
|
|
services.Configure<SettingOptions>(options =>
|
|
{
|
|
options.DefinitionProviders.AddIfNotContains(definitionProviders);
|
|
});
|
|
}
|
|
}
|
|
}
|