コード例 #1
0
 public FormController(IMediator mediator, IMapper mapper, IOptions <ApplicationCacheOptions> cacheOptions, ITokenService tokenService)
 {
     _cacheOptions = cacheOptions.Value;
     _mediator     = mediator;
     _mapper       = mapper;
     _tokenService = tokenService;
 }
コード例 #2
0
        // migrated
        private void ConfigureCache(IServiceCollection services)
        {
            var cacheOptions = new ApplicationCacheOptions();

            Configuration.GetSection(nameof(ApplicationCacheOptions)).Bind(cacheOptions);

            switch (cacheOptions.Implementation)
            {
            case "NoCache":
            {
                _container.RegisterInstance <ICacheService>(new NoCacheService());
                break;
            }

            case "RedisCache":
            {
                _container.RegisterSingleton <ICacheService, CacheService>();
                services.AddDistributedRedisCache(options =>
                    {
                        Configuration.GetSection("RedisCacheOptions").Bind(options);
                    });

                break;
            }

            case "MemoryDistributedCache":
            {
                _container.RegisterSingleton <ICacheService, CacheService>();
                services.AddDistributedMemoryCache();
                break;
            }
            }
        }
コード例 #3
0
        public static IServiceCollection AddCachingService(this IServiceCollection services,
                                                           IConfiguration configuration)
        {
            var cacheOptions = new ApplicationCacheOptions();

            configuration.GetSection(nameof(ApplicationCacheOptions)).Bind(cacheOptions);

            switch (cacheOptions.Implementation)
            {
            case "NoCache":
            {
                services.AddSingleton <ICacheService, NoCacheService>();
                break;
            }

            case "RedisCache":
            {
                services.AddSingleton <ICacheService, CacheService>();
                services.AddDistributedRedisCache(options =>
                    {
                        configuration.GetSection("RedisCacheOptions").Bind(options);
                    });

                break;
            }

            case "MemoryDistributedCache":
            {
                services.AddSingleton <ICacheService, CacheService>();
                services.AddDistributedMemoryCache();
                break;
            }
            }

            return(services);
        }
コード例 #4
0
 public StatisticsController(IMediator mediator, IConfiguration configuration, IOptions <ApplicationCacheOptions> cacheOptions)
 {
     _mediator      = mediator;
     _configuration = configuration;
     _cacheOptions  = cacheOptions.Value;
 }
コード例 #5
0
 public FormController(IMediator mediator, IOptions <ApplicationCacheOptions> cacheOptions)
 {
     _cacheOptions = cacheOptions.Value;
     _mediator     = mediator;
 }