/// <summary> /// Adds the in-memory service store. /// </summary> /// <param name="builder">The builder.</param> /// <param name="services">A list of services which will be added to the in-memory store.</param> /// <returns></returns> public static IServiceRegistryBuilder AddInMemoryStore(this IServiceRegistryBuilder builder, params Service[] services) { builder.Services.AddSingleton(services); builder.AddServiceStoreAsSingleton <InMemoryServiceStore>(); return(builder); }
/// <summary> /// Adds the in memory caching. /// </summary> /// <param name="builder">The builder.</param> /// <returns></returns> public static IServiceRegistryBuilder AddInMemoryCaching(this IServiceRegistryBuilder builder) { builder.Services.TryAddSingleton <IMemoryCache, MemoryCache>(); builder.Services.TryAddTransient(typeof(ICache <>), typeof(MemoryCache <>)); return(builder); }
/// <summary> /// Adds the service store cache. /// </summary> /// <typeparam name="T">The type of the concrete service store class that is registered in DI.</typeparam> /// <param name="builder">The builder.</param> /// <returns></returns> public static IServiceRegistryBuilder AddServiceStoreCache <T>(this IServiceRegistryBuilder builder) where T : class, IServiceStore { builder.Services.TryAddTransient(typeof(T)); builder.Services.AddTransient <IServiceStore, CachingServiceStore <T> >(); return(builder); }
/// <summary> /// Adds a service store as singleton. /// </summary> /// <typeparam name="T">Type of the service store</typeparam> /// <param name="builder">The builder.</param> /// <returns></returns> public static IServiceRegistryBuilder AddServiceStoreAsSingleton <T>(this IServiceRegistryBuilder builder) where T : class, IServiceStore { builder.Services.TryAddSingleton(typeof(T)); builder.Services.AddSingleton <IServiceStore, T>(); return(builder); }
/// <summary> /// Configures caching for IServiceStore /// </summary> /// <param name="builder">The builder.</param> /// <returns></returns> public static IServiceRegistryBuilder AddRegistryStoreCache(this IServiceRegistryBuilder builder) { builder.AddInMemoryCaching(); // add the caching decorators builder.AddServiceStoreCache <ServiceStore>(); return(builder); }
/// <summary> /// Configures EntityFramework implementation of IServiceStore. /// </summary> /// <typeparam name="TContext">The IConfigurationDbContext to use.</typeparam> /// <param name="builder">The builder.</param> /// <param name="storeOptionsAction">The store options action.</param> /// <returns></returns> public static IServiceRegistryBuilder AddRegistryStore <TContext>(this IServiceRegistryBuilder builder, Action <RegistryStoreOptions> storeOptionsAction = null) where TContext : DbContext, IRegistryDbContext { builder.Services.AddRegistryDbContext <TContext>(storeOptionsAction); builder.AddServiceStore <ServiceStore>(); return(builder); }
/// <summary> /// Configures EntityFramework implementation of IServiceStore /// </summary> /// <param name="builder">The builder.</param> /// <param name="storeOptionsAction">The store options action.</param> /// <returns></returns> public static IServiceRegistryBuilder AddRegistryStore(this IServiceRegistryBuilder builder, Action <RegistryStoreOptions> storeOptionsAction = null) { return(builder.AddRegistryStore <RegistryDbContext>(storeOptionsAction)); }