コード例 #1
0
        public PermissionDefinitionManager(
            IOptions <PermissionOptions> options,
            IServiceProvider serviceProvider)
        {
            Options          = options.Value;
            _serviceProvider = serviceProvider;

            _lazyPermissionDefinitions      = new Lazy <Dictionary <string, PermissionDefinition> >(CreatePermissionDefinitions, true);
            _lazyPermissionGroupDefinitions = new Lazy <Dictionary <string, PermissionGroupDefinition> >(CreatePermissionGroupDefinitions, true);
        }
コード例 #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);
        }