add culture based caching -> 0.0.4
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
|
||||
);
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user