/// <summary>
 /// Add your own custom ExpirationService to tell Cache Manager when to manually expire cache items
 /// </summary>
 /// <typeparam name="T">The ICacheExpirationService implementation to add to the DI container</typeparam>
 /// <param name="builder">The ICacheManagerBuilder provided by the AddCacheManager service registration</param>
 /// <returns>The expiration builder to add your custom cache registrations</returns>
 public static ICacheExpirationBuilder AddCustomExpirationService <T>(this ICacheManagerBuilder builder) where T : class, ICacheExpirationService
 {
     builder.Services.AddTransient <ICacheExpirationService, T>(s => s.GetService <T>());
     return(new CacheExpirationBuilder {
         Builder = builder
     });
 }
        /// <summary>
        /// Add the Entity Framework ExpirationService to tell Cache Manager to expire cache when the database has a registered expiration
        /// </summary>
        /// <param name="builder">The ICacheManagerBuilder provided by the AddCacheManager service registration</param>
        /// <param name="contextBuilder">The ContextBuilder to enable </param>
        /// <returns>The expiration builder to add your custom cache registrations</returns>
        public static ICacheExpirationBuilder AddEfExpirationService(this ICacheManagerBuilder builder, Action <DbContextOptionsBuilder> contextBuilder)
        {
            builder.Services.AddTransient <ICacheExpirationService, EfCacheExpirationService>();
            builder.Services.AddDbContext <CacheExpirationContext>(contextBuilder);
            builder.Services.AddTransient <ICacheExpirationContext>(s => s.GetService <CacheExpirationContext>());

            return(new CacheExpirationBuilder {
                Builder = builder
            });
        }
        /// <summary>
        /// Add the Entity Framework ExpirationService to tell Cache Manager to expire cache when the database has a registered expiration
        /// </summary>
        /// <param name="builder">The ICacheManagerBuilder provided by the AddCacheManager service registration</param>
        /// <param name="connectionString">The connection string or connection string name</param>
        /// <returns>The expiration builder to add your custom cache registrations</returns>
        public static ICacheExpirationBuilder AddEfExpirationService(this ICacheManagerBuilder builder, string connectionString = "DefaultConnection")
        {
            var migrationsAssembly = typeof(ServiceExtensions).GetTypeInfo().Assembly.GetName().Name;

            builder.Services.AddTransient <ICacheExpirationService, EfCacheExpirationService>();
            builder.Services.AddDbContext <CacheExpirationContext>(x =>
                                                                   x.UseSqlServer(connectionString, options =>
                                                                                  options.MigrationsAssembly(migrationsAssembly)
                                                                                  )
                                                                   );
            builder.Services.AddTransient <ICacheExpirationContext>(s => s.GetService <CacheExpirationContext>());

            return(new CacheExpirationBuilder {
                Builder = builder
            });
        }