示例#1
0
        public override void AddApiServices(IServiceCollection services, Type type)
        {
            var permission = ApiPermission.CreateDeny(
                this.PermissionType,
                this.To,
                this.OnNamespace,
                this.On,
                this.OnChild);

            services.AddInstance(permission);
        }
示例#2
0
        public override void AddApiServices(IServiceCollection services, Type type)
        {
            var permission = ApiPermission.CreateGrant(
                this.PermissionType,
                this.To,
                this.OnNamespace,
                this.On,
                this.OnChild);

            services.AddSingleton(permission);
        }
示例#3
0
        public override void ConfigureApi(IServiceCollection services, Type type)
        {
            var permission = ApiPermission.CreateGrant(
                this.PermissionType,
                this.To,
                this.OnNamespace,
                this.On,
                this.OnChild);

            services.AddInstance(permission);
        }
示例#4
0
        /// <summary>
        /// Configures an API configuration.
        /// </summary>
        /// <param name="configuration">
        /// An API configuration.
        /// </param>
        /// <param name="type">
        /// The API type on which this attribute was placed.
        /// </param>
        public override void Configure(
            ApiConfiguration configuration,
            Type type)
        {
            var permission = ApiPermission.CreateDeny(
                this.PermissionType,
                this.To,
                this.OnNamespace,
                this.On,
                this.OnChild);

            configuration.AddPermission(permission);
        }
        /// <summary>
        /// Adds an API permission to an API configuration.
        /// </summary>
        /// <param name="configuration">
        /// An API configuration.
        /// </param>
        /// <param name="permission">
        /// An API permission.
        /// </param>
        public static void AddPermission(
            this ApiConfiguration configuration,
            ApiPermission permission)
        {
            Ensure.NotNull(configuration, "configuration");
            Ensure.NotNull(permission, "permission");
            var permissions = configuration.GetProperty<List<ApiPermission>>(Permissions);
            if (permissions == null)
            {
                permissions = new List<ApiPermission>();
                configuration.SetProperty(Permissions, permissions);
            }

            permissions.Add(permission);
        }
        /// <summary>
        /// Adds an API permission to an API configuration.
        /// </summary>
        /// <param name="configuration">
        /// An API configuration.
        /// </param>
        /// <param name="permission">
        /// An API permission.
        /// </param>
        public static void AddPermission(
            this ApiConfiguration configuration,
            ApiPermission permission)
        {
            Ensure.NotNull(configuration, "configuration");
            Ensure.NotNull(permission, "permission");
            var permissions = configuration.GetProperty <List <ApiPermission> >(Permissions);

            if (permissions == null)
            {
                permissions = new List <ApiPermission>();
                configuration.SetProperty(Permissions, permissions);
            }

            permissions.Add(permission);
        }