Esempio n. 1
0
        public static IUnleashServiceCollection WithWebHostControlledLifetime(this IUnleashServiceCollection serviceCollection)
        {
            if (serviceCollection == null)
            {
                throw new ArgumentNullException(nameof(serviceCollection));
            }

            serviceCollection.AddTransient <IStartupFilter, WebHostControlledLifetimeStartupFilter>();
            return(serviceCollection);
        }
Esempio n. 2
0
        public static IUnleashServiceCollection WithSynchronousFlagLoadingOnStartup(this IUnleashServiceCollection serviceCollection, bool enabled = true, bool onlyOnEmptyCache = false, TimeSpan?timeout = null)
        {
            if (serviceCollection == null)
            {
                throw new ArgumentNullException(nameof(serviceCollection));
            }

            if (enabled)
            {
                serviceCollection.AddTransient <IStartupFilter>(
                    sp =>
                {
                    var services = sp.GetRequiredService <IUnleashServices>();
                    return(new SynchronousFlagLoadingStartupFilter(
                               sp, services, onlyOnEmptyCache, timeout ?? DefaultTimeout));
                });
            }

            return(serviceCollection);
        }