Exemplo n.º 1
0
 public async Task Invoke(HttpContext context, IJsonLocalizationCache cache)
 {
     await _next.Invoke(context);
     if (cache.Dirty)
     {
         _logger.LogInformation($"path={context.Request.Path} Dirty={cache.Dirty}");
         cache.SaveAll();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Creates a new <see cref="JsonStringLocalizer" />.
 /// </summary>
 /// <param name="type">The base name of the embedded resource in the <see cref="Assembly" /> that contains the strings.</param>
 /// <param name="cache"></param>
 /// <param name="logger"></param>
 /// <param name="options"></param>
 /// <param name="translater"></param>
 /// <summary>
 ///     Intended for testing purposes only.
 /// </summary>
 public JsonStringLocalizer(string type, IJsonLocalizationCache cache, ILogger<JsonStringLocalizer> logger, IOptions<DependencyInjection.LocalizationOptions> options, ITranslater translater)
 {
     _type = type;
     _cache = cache;
     _logger = logger;
     _option = options;
     _translater = translater;
     _defaultCulture = options.Value.MissingTranslation;
 }
 /// <summary>
 ///     Creates a new <see cref="JsonStringLocalizer" />.
 /// </summary>
 /// <param name="localizationOptions">The <see cref="IOptions{TOptions}" />.</param>
 /// <param name="cache">Used entries will be cached</param>
 /// <param name="logger"></param>
 /// <param name="translater">Missed entries will be added by asking the translater for a translation</param>
 public JsonStringLocalizerFactory(IOptions<DependencyInjection.LocalizationOptions> localizationOptions, 
     IJsonLocalizationCache cache, 
     ILogger<JsonStringLocalizer> logger,
     ITranslater translater)
 {
     _resourcesRelativePath = localizationOptions.Value.ResourcesPath ?? string.Empty;
     _cache = cache;
     _logger = logger;
     _option = localizationOptions;
     _translater = translater;
 }
 /// <summary>
 ///     Creates a new <see cref="WithCultureJsonStringLocalizer" />.
 /// </summary>
 /// <param name="type">The base name of the embedded resource in the <see cref="Assembly" /> that contains the strings.</param>
 /// <param name="cache"></param>
 /// <param name="culture">The specific <see cref="CultureInfo" /> to use.</param>
 public WithCultureJsonStringLocalizer(string type, IJsonLocalizationCache cache, CultureInfo culture, ILogger<JsonStringLocalizer> logger, IOptions<DependencyInjection.LocalizationOptions> options, ITranslater translate)
     : base(type, cache, logger, options, translate)
 {
     _culture = culture;
 }