public BackgroundServicesManager(
            [NotNull, ItemNotNull] IEnumerable <IBackgroundService> backgroundServices,
            [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger, [NotNull] ITypeHelper typeHelper,
            [NotNull] IFeatureToggles featureToggles)
        {
            if (backgroundServices == null)
            {
                throw new ArgumentNullException(nameof(backgroundServices));
            }

            _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager));
            _Logger         = logger ?? throw new ArgumentNullException(nameof(logger));
            _TypeHelper     = typeHelper ?? throw new ArgumentNullException(nameof(typeHelper));
            _FeatureToggles = featureToggles ?? throw new ArgumentNullException(nameof(featureToggles));

            _BackgroundServices = backgroundServices.ToList();
        }
        private static bool IsFeatureToggleEnabled(IFeatureToggles _featureToggles, string featureToggle)
        {
            var toggleEnabled = false;

            if (_featureToggles != null && !string.IsNullOrWhiteSpace(featureToggle))
            {
                try
                {
                    var property      = _featureToggles.GetType().GetProperty(featureToggle);
                    var propertyValue = property.GetValue(_featureToggles, null);

                    if (propertyValue != null)
                    {
                        toggleEnabled = Convert.ToBoolean(propertyValue);
                    }
                }
                catch (SystemException ex) when(ex is InvalidCastException || ex is FormatException)
                {
                    toggleEnabled = false;
                }
            }

            return(toggleEnabled);
        }
 public FizzBuzzService(IFeatureToggles <FizzBuzzFeature> featureToggles)
 {
     _featureToggles = featureToggles;
 }
 public FeatureToggleTagHelper(IFeatureToggles featureToggles)
 {
     _featureToggles = featureToggles;
 }
예제 #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IFeatureToggles features)
        {
            loggerFactory.AddConsole();

            app.UseExceptionHandler("/error.html");
            #region Depricated - Use Static Error Page
            //if (env.IsDevelopment())
            //{
            //    app.UseBrowserLink();
            //    app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //    app.UseExceptionHandler("/Home/Error");
            //}
            #endregion

            if (features.EnableDeveloperExceptions)
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(async(AppContext, next) =>
            {
                if (AppContext.Request.Path.Value.Contains("invalid"))
                {
                    throw new Exception("Error2!");
                }
                await next();
            });

            app.UseAuthentication();
            #region Depricated - Use UseFileServer for all Static MiddleWare
            //app.UseStaticFiles();
            #endregion
            app.UseMvc(routes =>
            {
                routes.MapRoute("Default",
                                "{controller=Home}/{action=Index}/{id:int?}");
            });

            app.UseFileServer();
        }
 public FeatureToggleFilter(ILogger <FeatureToggleFilter> logger, IWebConfiguration configuration)
 {
     _logger         = logger;
     _featureToggles = configuration.FeatureToggles;
 }
예제 #7
0
 public FeatureToggleFilter(ILogger <FeatureToggleFilter> logger, IFeatureToggles featureToggles)
 {
     _logger         = logger;
     _featureToggles = featureToggles;
 }
예제 #8
0
 public static bool?IsEnabled([NotNull] this IFeatureToggles featureToggles, [NotNull] string key)
 => featureToggles.GetByKey(key).IsEnabled;
예제 #9
0
 public static bool IsEnabled([NotNull] this IFeatureToggles featureToggles, [NotNull] string key, bool defaultIfUnspecified)
 => featureToggles.IsEnabled(key) ?? defaultIfUnspecified;