add culture based caching
This commit is contained in:
@@ -20,101 +20,116 @@ namespace ResourceString.Net.Logic.Properties
|
||||
|
||||
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
|
||||
|
||||
|
||||
internal static class ResourceStringMembers
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("ResourceStringMembers", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("ResourceStringMembers", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString resourceId, IResourceString resourceManagerPropertyName) => new FormattedResourceString(
|
||||
public static IResourceString From(IResourceString resourceId, IResourceString resourceManagerPropertyName) => AddToCultureCache(new FormattedResourceString(
|
||||
Format,
|
||||
GetDefaultCulture,
|
||||
resourceId,
|
||||
resourceManagerPropertyName
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
internal static class ResourceFormatClassMembers
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("ResourceFormatClassMembers", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("ResourceFormatClassMembers", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString resourceId, IResourceString resourceManagerPropertyName, IResourceString fromMethodDefinition) => new FormattedResourceString(
|
||||
public static IResourceString From(IResourceString resourceId, IResourceString resourceManagerPropertyName, IResourceString fromMethodDefinition) => AddToCultureCache(new FormattedResourceString(
|
||||
Format,
|
||||
GetDefaultCulture,
|
||||
resourceId,
|
||||
resourceManagerPropertyName,
|
||||
fromMethodDefinition
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
internal static class ResourceFormatClassFromMethod
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("ResourceFormatClassFromMethod", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("ResourceFormatClassFromMethod", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString fromMethodSignature, IResourceString parameterNames) => new FormattedResourceString(
|
||||
public static IResourceString From(IResourceString fromMethodSignature, IResourceString parameterNames) => AddToCultureCache(new FormattedResourceString(
|
||||
Format,
|
||||
GetDefaultCulture,
|
||||
fromMethodSignature,
|
||||
parameterNames
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
internal static class ResourcesClassTemplate
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("ResourcesClassTemplate", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("ResourcesClassTemplate", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString ns, IResourceString className, IResourceString resourceManagerRegion, IResourceString resourceRegions) => new FormattedResourceString(
|
||||
public static IResourceString From(IResourceString ns, IResourceString className, IResourceString resourceManagerRegion, IResourceString resourceRegions) => AddToCultureCache(new FormattedResourceString(
|
||||
Format,
|
||||
GetDefaultCulture,
|
||||
ns,
|
||||
className,
|
||||
resourceManagerRegion,
|
||||
resourceRegions
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
internal static class ResourceManagerMemberTemplate
|
||||
{
|
||||
private static readonly Lazy<IResourceString> LazyFormat = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("ResourceManagerMemberTemplate", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("ResourceManagerMemberTemplate", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
public static IResourceString Format => LazyFormat.Value;
|
||||
|
||||
public static IResourceString From(IResourceString className, IResourceString resourceManagerTypeName) => new FormattedResourceString(
|
||||
public static IResourceString From(IResourceString className, IResourceString resourceManagerTypeName) => AddToCultureCache(new FormattedResourceString(
|
||||
Format,
|
||||
GetDefaultCulture,
|
||||
className,
|
||||
resourceManagerTypeName
|
||||
);
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
#region DefaultPropertyName_ResourceManager
|
||||
|
||||
private static readonly Lazy<IResourceString> LazyDefaultPropertyName_ResourceManager = new Lazy<IResourceString>(
|
||||
() => new ResourceManagerString("DefaultPropertyName_ResourceManager", ResourceManager, CultureInfo.CurrentCulture),
|
||||
() => AddToCultureCache(new ResourceManagerString("DefaultPropertyName_ResourceManager", ResourceManager, GetDefaultCulture)),
|
||||
LazyThreadSafetyMode.PublicationOnly
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user