mirror of https://github.com/abpframework/abp.git
7 changed files with 56 additions and 29 deletions
@ -0,0 +1,9 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Settings |
||||
|
{ |
||||
|
public interface ISettingValueProviderManager |
||||
|
{ |
||||
|
List<ISettingValueProvider> Providers { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.Settings |
||||
|
{ |
||||
|
public class SettingValueProviderManager : ISettingValueProviderManager, ISingletonDependency |
||||
|
{ |
||||
|
public List<ISettingValueProvider> Providers => _lazyProviders.Value; |
||||
|
protected SettingOptions Options { get; } |
||||
|
private readonly Lazy<List<ISettingValueProvider>> _lazyProviders; |
||||
|
|
||||
|
public SettingValueProviderManager( |
||||
|
IServiceProvider serviceProvider, |
||||
|
IOptions<SettingOptions> options) |
||||
|
{ |
||||
|
|
||||
|
Options = options.Value; |
||||
|
|
||||
|
_lazyProviders = new Lazy<List<ISettingValueProvider>>( |
||||
|
() => Options |
||||
|
.ValueProviders |
||||
|
.Select(type => serviceProvider.GetRequiredService(type) as ISettingValueProvider) |
||||
|
.ToList(), |
||||
|
true |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue