add culture based caching -> 0.0.4

This commit is contained in:
2023-05-20 11:30:33 +00:00
parent 37a7c50e4d
commit 2642f54334
19 changed files with 186 additions and 55 deletions

View File

@@ -5,7 +5,7 @@
#region {0}
private static readonly Lazy<IResourceString> Lazy{0} = new Lazy<IResourceString>(
() => new ResourceManagerString("{0}", {1}, CultureInfo.CurrentCulture),
() => AddToCultureCache(new ResourceManagerString("{0}", {1}, GetDefaultCulture)),
LazyThreadSafetyMode.PublicationOnly
);
@@ -20,7 +20,7 @@
internal static class {0}
{{
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
() => new ResourceManagerString("{0}", {1}, CultureInfo.CurrentCulture),
() => AddToCultureCache(new ResourceManagerString("{0}", {1}, GetDefaultCulture)),
LazyThreadSafetyMode.PublicationOnly
);
@@ -32,10 +32,11 @@
</data>
<data name="ResourceFormatClassFromMethod" xml:space="preserve">
<value>
public static IResourceString From({0}) => new FormattedResourceString(
public static IResourceString From({0}) => AddToCultureCache(new FormattedResourceString(
Format,
GetDefaultCulture,
{1}
);
));
</value>
<comment>0 = FromMethodSignature, 1 = ParameterNames</comment>
</data>
@@ -71,6 +72,16 @@ namespace {0}
public static ResourceManager ResourceManager => _ResourceManager.Value;
private static CultureInfo GetDefaultCulture()
{{
return CultureInfo.CurrentCulture;
}}
private static IResourceString AddToCultureCache(IResourceString source)
{{
return new CultureBasedCachedString(source, GetDefaultCulture);
}}
#endregion // ResourceManager
</value>
<comment>0 = ResourceManagerTypeName, 1 = ClassName</comment>