public PermissionDefinitionManager(
            IOptions <PermissionOptions> options,
            IServiceProvider serviceProvider)
        {
            Options          = options.Value;
            _serviceProvider = serviceProvider;

            _lazyProviders                  = new Lazy <List <IPermissionDefinitionProvider> >(CreatePermissionProviders, true);
            _lazyPermissionDefinitions      = new Lazy <Dictionary <string, PermissionDefinition> >(CreatePermissionDefinitions, true);
            _lazyPermissionGroupDefinitions = new Lazy <Dictionary <string, PermissionGroupDefinition> >(CreatePermissionGroupDefinitions, true);
        }
Esempio n. 2
0
        public PermissionChecker(
            IOptions <PermissionOptions> options,
            IServiceProvider serviceProvider,
            IHttpContextPrincipalAccessor principalAccessor,
            IPermissionDefinitionManager permissionDefinitionManager)
        {
            PrincipalAccessor           = principalAccessor;
            PermissionDefinitionManager = permissionDefinitionManager;
            Options = options.Value;

            _lazyProviders = new Lazy <List <IPermissionValueProvider> >(
                () => Options
                .ValueProviders
                .Select(c => serviceProvider.GetRequiredService(c) as IPermissionValueProvider)
                .ToList(),
                true
                );
        }