public static IServiceCollection AddDistributedNullCache(this IServiceCollection services)
 {
     if (services == null)
     {
         throw new ArgumentNullException("services");
     }
     ServiceCollectionDescriptorExtensions.TryAdd(services, ServiceDescriptor.Singleton <IDistributedCache, NullDistributedCache>());
     return(services);
 }
Exemple #2
0
        //
        // Summary:
        //     /// Adds PoorMan's Grid FilterService
        //     to the /// Microsoft.Extensions.DependencyInjection.IServiceCollection. ///
        //
        // Parameters:
        //   services:
        //     The Microsoft.Extensions.DependencyInjection.IServiceCollection to add services
        //     to.
        //
        // Returns:
        //     The Microsoft.Extensions.DependencyInjection.IServiceCollection so that additional
        //     calls can be chained.
        public static IServiceCollection AddPoorMansGridFilterService(this IServiceCollection services, TextSearchOption options = TextSearchOption.Default)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            OptionsServiceCollectionExtensions.AddOptions(services);
            ServiceCollectionDescriptorExtensions.TryAdd(services, ServiceDescriptor.Scoped <IFilterService>(s => new FilterService(options)));

            return(services);
        }
Exemple #3
0
        //
        // Summary:
        //     /// Adds a non distributed in memory implementation of BlitzCache
        //     to the /// Microsoft.Extensions.DependencyInjection.IServiceCollection. ///
        //
        // Parameters:
        //   services:
        //     The Microsoft.Extensions.DependencyInjection.IServiceCollection to add services
        //     to.
        //
        // Returns:
        //     The Microsoft.Extensions.DependencyInjection.IServiceCollection so that additional
        //     calls can be chained.
        public static IServiceCollection AddBlitzCache(this IServiceCollection services, long defaultMilliseconds = 60000)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            OptionsServiceCollectionExtensions.AddOptions(services);
            ServiceCollectionDescriptorExtensions.TryAdd(services, ServiceDescriptor.Singleton <IBlitzCache>(new BlitzCache(defaultMilliseconds)));

            return(services);
        }
 /// <inheritdoc cref="ServiceCollectionDescriptorExtensions.TryAdd(IServiceCollection, ServiceDescriptor)"/>
 /// <returns>A reference to this instance after the operation has completed.</returns>
 public static IServiceCollection TryAdd(this IServiceCollection collection, ServiceDescriptor descriptor)
 {
     ServiceCollectionDescriptorExtensions.TryAdd(collection, descriptor);
     return(collection);
 }
 /// <inheritdoc cref="ServiceCollectionDescriptorExtensions.TryAdd(IServiceCollection, IEnumerable{ServiceDescriptor})"/>
 /// <returns>A reference to this instance after the operation has completed.</returns>
 public static IServiceCollection TryAdd(this IServiceCollection collection, IEnumerable <ServiceDescriptor> descriptors)
 {
     ServiceCollectionDescriptorExtensions.TryAdd(collection, descriptors);
     return(collection);
 }
Exemple #6
0
 public static IServiceCollection AddSnailRedisMemoryCache(this IServiceCollection services, Action <RedisCacheOptions> setupAction)
 {
     services.AddStackExchangeRedisCache(setupAction);
     ServiceCollectionDescriptorExtensions.TryAdd(services, ServiceDescriptor.Singleton <ISnailCache, SnailRedisCache>());
     return(services);
 }
 public static IServiceCollection AddSnailMemoryCache(this IServiceCollection services)
 {
     ServiceCollectionDescriptorExtensions.TryAdd(services, ServiceDescriptor.Singleton <ISnailCache, SnailMemoryCache>());
     services.AddMemoryCache();
     return(services);
 }