public static IProviderOptionsWithDecorator <IEasyCachingProvider> DecorateWithCircuitBreaker( this IProviderOptionsWithDecorator <IEasyCachingProvider> options, ICircuitBreakerParameters initParameters, ICircuitBreakerParameters executeParameters, Func <Exception, bool> exceptionFilter) { return(options.Decorate((name, serviceProvider, cachingProviderFactory) => () => new DecoratedEasyCachingProvider( name, cachingProviderFactory.WithCircuitBreaker(initParameters, executeParameters, exceptionFilter)) )); }
public static IProviderOptionsWithDecorator <IEasyCachingProvider> DecorateWithFallback( this IProviderOptionsWithDecorator <IEasyCachingProvider> options, Func <string, IServiceProvider, IEasyCachingProvider> fallbackCachingProviderFactory, Func <Exception, bool> exceptionFilter) { return(options.Decorate((name, serviceProvider, cachingProviderFactory) => () => new DecoratedEasyCachingProvider( name, cachingProviderFactory.WithFallback( fallbackCachingProviderFactory(name, serviceProvider), exceptionFilter)) )); }
public static TProvider CreateDecoratedProvider <TProvider>( this IProviderOptionsWithDecorator <TProvider> options, string name, IServiceProvider serviceProvider, Func <TProvider> cachingProviderFactory) where TProvider : class, IEasyCachingProviderBase { if (options.ProviderFactoryDecorator == null) { return(cachingProviderFactory()); } else { var decoratedProviderFactory = options.ProviderFactoryDecorator(name, serviceProvider, cachingProviderFactory); return(decoratedProviderFactory()); } }
public static IProviderOptionsWithDecorator <TProvider> Decorate <TProvider>( this IProviderOptionsWithDecorator <TProvider> options, ProviderFactoryDecorator <TProvider> factoryDecorator) where TProvider : class, IEasyCachingProviderBase { if (options.ProviderFactoryDecorator == null) { options.ProviderFactoryDecorator = factoryDecorator; } else { var existingFactoryDecorator = options.ProviderFactoryDecorator; options.ProviderFactoryDecorator = (name, serviceProvider, cachingProviderFactory) => { var factoryDecoratedWithExistingDecorator = existingFactoryDecorator(name, serviceProvider, cachingProviderFactory); return(factoryDecorator(name, serviceProvider, factoryDecoratedWithExistingDecorator)); }; } return(options); }