namespace Ocelot.Cache.CacheManager { using Configuration; using Configuration.File; using DependencyInjection; using global::CacheManager.Core; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using System; public static class OcelotBuilderExtensions { public static IOcelotBuilder AddCacheManager(this IOcelotBuilder builder, Action settings) { var cacheManagerOutputCache = CacheFactory.Build("OcelotOutputCache", settings); var ocelotOutputCacheManager = new OcelotCacheManagerCache(cacheManagerOutputCache); builder.Services.RemoveAll(typeof(ICacheManager)); builder.Services.RemoveAll(typeof(IOcelotCache)); builder.Services.AddSingleton>(cacheManagerOutputCache); builder.Services.AddSingleton>(ocelotOutputCacheManager); var ocelotConfigCacheManagerOutputCache = CacheFactory.Build("OcelotConfigurationCache", settings); var ocelotConfigCacheManager = new OcelotCacheManagerCache(ocelotConfigCacheManagerOutputCache); builder.Services.RemoveAll(typeof(ICacheManager)); builder.Services.RemoveAll(typeof(IOcelotCache)); builder.Services.AddSingleton>(ocelotConfigCacheManagerOutputCache); builder.Services.AddSingleton>(ocelotConfigCacheManager); var fileConfigCacheManagerOutputCache = CacheFactory.Build("FileConfigurationCache", settings); var fileConfigCacheManager = new OcelotCacheManagerCache(fileConfigCacheManagerOutputCache); builder.Services.RemoveAll(typeof(ICacheManager)); builder.Services.RemoveAll(typeof(IOcelotCache)); builder.Services.AddSingleton>(fileConfigCacheManagerOutputCache); builder.Services.AddSingleton>(fileConfigCacheManager); builder.Services.RemoveAll(typeof(ICacheKeyGenerator)); builder.Services.AddSingleton(); return builder; } } }