mirror of https://github.com/abpframework/abp.git
5 changed files with 50 additions and 29 deletions
@ -0,0 +1,9 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.Authorization.Permissions |
|||
{ |
|||
public interface IPermissionValueProviderManager |
|||
{ |
|||
IReadOnlyList<IPermissionValueProvider> ValueProviders { 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.Authorization.Permissions |
|||
{ |
|||
public class PermissionValueProviderManager : IPermissionValueProviderManager, ISingletonDependency |
|||
{ |
|||
public IReadOnlyList<IPermissionValueProvider> ValueProviders => _lazyProviders.Value; |
|||
private readonly Lazy<List<IPermissionValueProvider>> _lazyProviders; |
|||
|
|||
protected PermissionOptions Options { get; } |
|||
|
|||
public PermissionValueProviderManager( |
|||
IServiceProvider serviceProvider, |
|||
IOptions<PermissionOptions> options) |
|||
{ |
|||
Options = options.Value; |
|||
|
|||
_lazyProviders = new Lazy<List<IPermissionValueProvider>>( |
|||
() => Options |
|||
.ValueProviders |
|||
.Select(c => serviceProvider.GetRequiredService(c) as IPermissionValueProvider) |
|||
.ToList(), |
|||
true |
|||
); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue