public static IServiceCollection AddCosmosCache()

in src/CosmosCacheServiceCollectionExtensions.cs [24:51]


        public static IServiceCollection AddCosmosCache(this IServiceCollection services, Action<CosmosCacheOptions> setupAction)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (setupAction == null)
            {
                throw new ArgumentNullException(nameof(setupAction));
            }

            services.AddOptions();
            services.Configure(setupAction);
            services.Add(ServiceDescriptor.Singleton<IDistributedCache, CosmosCache>((IServiceProvider provider) =>
            {
                IOptionsMonitor<CosmosCacheOptions> optionsMonitor = provider.GetService<IOptionsMonitor<CosmosCacheOptions>>();
                if (optionsMonitor != null)
                {
                    return new CosmosCache(optionsMonitor);
                }

                IOptions<CosmosCacheOptions> options = provider.GetRequiredService<IOptions<CosmosCacheOptions>>();
                return new CosmosCache(options);
            }));

            return services;
        }