Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Valdis Iljuconoks committed May 5, 2024
1 parent 187c7b8 commit 74556cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
// ReSharper disable once CheckNamespace
namespace DbLocalizationProvider.AspNetCore;

/// <summary>
/// Unfortunately extension methods needs to have their homes somewhere
/// </summary>
public static class IApplicationBuilderClientsideExtensions
{
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private static ICacheManager _cache;
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

/// <summary>
/// Makes sure that usage of the clientside resource provider is added to your app.
Expand All @@ -25,8 +30,9 @@ public static IApplicationBuilder UseDbLocalizationClientsideProvider(this IAppl
AppContext.Configure(builder.ApplicationServices.GetRequiredService<IHttpContextAccessor>());
_cache = builder.ApplicationServices.GetRequiredService<ICacheManager>();

var cacheManager = builder.ApplicationServices.GetService<ICacheManager>();
var cacheManager = builder.ApplicationServices.GetRequiredService<ICacheManager>();
cacheManager.OnRemove += OnRemove;

builder.ApplicationServices
.GetRequiredService<IHostApplicationLifetime>()
.ApplicationStopping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public IEnumerable<LocalizationResource> Execute(GetAllResources.Query query)

// if keys = 0, execute inner query to actually get resources from the db
// this is usually called during initialization when cache is not yet filled up
if (_configurationContext.Value.BaseCacheManager.KnownKeyCount == 0)
if (_configurationContext.Value._baseCacheManager.KnownKeyCount == 0)
{
return _inner.Execute(query);
}

var result = new List<LocalizationResource>();
var keys = _configurationContext.Value.BaseCacheManager.KnownKeys;
var keys = _configurationContext.Value._baseCacheManager.KnownKeys;

foreach (var key in keys)
{
Expand Down

0 comments on commit 74556cb

Please sign in to comment.