Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheKeyProvider"/> class.
        /// </summary>
        /// <param name="hashCalculator">The <see cref="Caching.HashCalculator"/>.</param>
        /// <param name="cacheOptions">The <see cref="Caching.CacheOptions"/>.</param>
        public CacheKeyProvider(
            HashCalculator hashCalculator,
            CacheOptions cacheOptions
            )
        {
            HashCalculator = hashCalculator ?? throw new  ArgumentNullException(nameof(hashCalculator));
            CacheOptions   = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));

            JsonSerializerOptions = new JsonSerializerOptions();
            JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodResultCache"/> class.
 /// </summary>
 /// <param name="cacheOptions">The <see cref="CacheOptions"/>.</param>
 /// <param name="cacheKeyProvider">The <see cref="Caching.CacheKeyProvider"/>.</param>
 /// <param name="distributedCache">The <see cref="IDistributedCache"/>.</param>
 /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
 public MethodResultCache(
     CacheOptions cacheOptions,
     CacheKeyProvider cacheKeyProvider,
     IDistributedCache distributedCache,
     ILoggerFactory loggerFactory
     )
 {
     CacheOptions     = cacheOptions ?? throw new ArgumentNullException(nameof(cacheOptions));
     DistributedCache = distributedCache ?? throw new ArgumentNullException(nameof(distributedCache));
     CacheKeyProvider = cacheKeyProvider ?? throw new ArgumentNullException(nameof(cacheKeyProvider));
     Logger           = loggerFactory?.CreateLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory));
 }