/// <summary>
        /// Provides a way to specify an inline disabled feature handler.
        /// </summary>
        /// <param name="builder">The feature management builder.</param>
        /// <param name="handler">The inline handler for disabled features.</param>
        /// <returns>The feature management builder.</returns>
        public static IFeatureManagementBuilder UseDisabledFeaturesHandler(this IFeatureManagementBuilder builder, Action <IEnumerable <string>, ActionExecutingContext> handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            builder.UseDisabledFeaturesHandler(new InlineDisabledFeaturesHandler(handler));

            return(builder);
        }
예제 #2
0
 public FeatureManagementBuilder(IFeatureManagementBuilder baseFeatureManagementBuilder)
 {
     _baseFeatureManagementBuilder = baseFeatureManagementBuilder;
 }
        /// <summary>
        /// Registers a disabled feature handler. This will be invoked for MVC actions that require a feature that is not enabled.
        /// </summary>
        /// <param name="builder">The feature management builder.</param>
        /// <param name="disabledFeaturesHandler">The disabled feature handler.</param>
        /// <returns>The feature management builder.</returns>
        public static IFeatureManagementBuilder UseDisabledFeaturesHandler(this IFeatureManagementBuilder builder, IDisabledFeaturesHandler disabledFeaturesHandler)
        {
            builder.Services.AddSingleton <IDisabledFeaturesHandler>(disabledFeaturesHandler ?? throw new ArgumentNullException(nameof(disabledFeaturesHandler)));

            return(builder);
        }
예제 #4
0
        /// <summary>
        /// Registers an inline disabled action handler. This will be invoked when an MVC action is disabled because it
        /// requires all or any of a set of features to be enabled but the features are not enabled.
        /// </summary>
        /// <param name="builder">The feature management builder.</param>
        /// <param name="handler">The inline handler for disabled actions.</param>
        /// <returns>The feature management builder.</returns>
        public static IFeatureManagementBuilder <TFeature> UseDisabledActionHandler <TFeature>(this IFeatureManagementBuilder <TFeature> builder, Action <IEnumerable <TFeature>, ActionExecutingContext> handler)
            where TFeature : struct, Enum
        {
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            builder.UseDisabledActionHandler(new InlineDisabledActionHandler <TFeature>(handler));

            return(builder);
        }
예제 #5
0
        /// <summary>
        /// Registers a disabled action handler. This will be invoked when an MVC action is disabled because it requires
        /// all or any of a set of features to be enabled but the features are not enabled.
        /// </summary>
        /// <param name="builder">The feature management builder.</param>
        /// <param name="disabledActionHandler">The disabled action handler.</param>
        /// <returns>The feature management builder.</returns>
        public static IFeatureManagementBuilder <TFeature> UseDisabledActionHandler <TFeature>(this IFeatureManagementBuilder <TFeature> builder, IDisabledActionHandler <TFeature> disabledActionHandler)
            where TFeature : struct, Enum
        {
            builder.Services.AddSingleton(disabledActionHandler ?? throw new ArgumentNullException(nameof(disabledActionHandler)));

            return(builder);
        }
        private static IFeatureManagementBuilder <TFeature> AddCoreServices <TFeature>(this IFeatureManagementBuilder <TFeature> featureManagementBuilder)
            where TFeature : struct, Enum
        {
            featureManagementBuilder.Services.AddSingleton <IFeatureManager <TFeature>, FeatureManager <TFeature> >();
            featureManagementBuilder.Services.AddScoped <IFeatureManagerSnapshot <TFeature>, FeatureManagerSnapshot <TFeature> >();

            featureManagementBuilder.Services.TryAddSingleton <IFeatureEnumParser <TFeature>, FeatureEnumParser <TFeature> >();

            return(featureManagementBuilder);
        }