Class CachedResourceManager
A wrapper around a default ResourceManager instance that caches retrieved objects.
public class CachedResourceManager : ResourceManager
- Inheritance
-
CachedResourceManager
- Inherited Members
Constructors
CachedResourceManager(ResourceManager)
Initializes a new instance of the CachedResourceManager class that caches retrieved objects.
public CachedResourceManager(ResourceManager wrapped)
Parameters
wrappedResourceManagerThe wrapped resource manager to get the actual objects from.
Properties
BaseName
Gets the root name of the resource files that the ResourceManager searches for resources.
public override string BaseName { get; }
Property Value
- string
The root name of the resource files that the ResourceManager searches for resources.
IgnoreCase
Gets or sets a value indicating whether the current instance allows case-insensitive resource lookups in the GetString(string) and GetObject(string) methods.
public override bool IgnoreCase { get; set; }
Property Value
- bool
A value indicating whether the case of the resource names should be ignored.
ResourceSetType
Gets the Type of the ResourceSet the ResourceManager uses to construct a ResourceSet object.
public override Type ResourceSetType { get; }
Property Value
- Type
The Type of the ResourceSet the ResourceManager uses to construct a ResourceSet object.
Methods
EnsureActive(Type)
Ensures that the specified original resource manager used by targetType
is replaced by a CachedResourceManager instance wrapping the original instance.
public static void EnsureActive(Type targetType)
Parameters
targetTypeTypeA auto-generated resource type that should use a CachedResourceManager instance wrapping the original resource manager.
Equals(object)
Determines whether the specified object is equal to this instance.
public override bool Equals(object obj)
Parameters
Returns
Exceptions
- NullReferenceException
The
objparameter isnull.
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
GetObject(string)
Returns the value of the specified object resource.
public override object GetObject(string name)
Parameters
namestringThe name of the resource to get.
Returns
- object
The value of the resource localized for the caller's current culture settings. If a match is not possible,
nullis returned. The resource value can benull.
Exceptions
- ArgumentNullException
The
nameparameter isnull.- MissingManifestResourceException
No usable set of resources has been found, and there are no neutral culture resources.
GetObject(string, CultureInfo)
Gets the value of the object resource localized for the specified culture.
public override object GetObject(string name, CultureInfo culture)
Parameters
namestringThe name of the resource to get.
cultureCultureInfoThe CultureInfo object that represents the culture for which the resource is localized. Note that if the resource is not localized for this culture, the lookup will fall back using the culture's Parent property, stopping after checking in the neutral culture. If this value is null, the CultureInfo is obtained using the culture's CurrentUICulture property.
Returns
- object
The value of the resource, localized for the specified culture. If a "best match" is not possible,
nullis returned.
Exceptions
- ArgumentNullException
The
nameparameter isnull.- MissingManifestResourceException
No usable set of resources have been found, and there are no neutral culture resources.
GetResourceSet(CultureInfo, bool, bool)
Gets the ResourceSet for a particular culture.
public override ResourceSet GetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
Parameters
cultureCultureInfoThe CultureInfo to look for.
createIfNotExistsboolIf true and if the ResourceSet has not been loaded yet, load it.
tryParentsboolIf the ResourceSet cannot be loaded, try parent CultureInfo objects to see if they exist.
Returns
- ResourceSet
The specified ResourceSet.
Exceptions
- ArgumentNullException
The
cultureparameter isnull.
GetString(string)
Returns the value of the specified string resource.
public override string GetString(string name)
Parameters
namestringThe name of the resource to get.
Returns
- string
The value of the resource localized for the caller's current culture settings. If a match is not possible,
nullis returned.
Exceptions
- ArgumentNullException
The
nameparameter isnull.- InvalidOperationException
The value of the specified resource is not a string.
- MissingManifestResourceException
No usable set of resources has been found, and there are no neutral culture resources.
GetString(string, CultureInfo)
Gets the value of the string resource localized for the specified culture.
public override string GetString(string name, CultureInfo culture)
Parameters
namestringThe name of the resource to get.
cultureCultureInfoThe CultureInfo object that represents the culture for which the resource is localized. Note that if the resource is not localized for this culture, the lookup will fall back using the culture's Parent property, stopping after looking in the neutral culture. If this value is
null, the CultureInfo is obtained using the culture's CurrentUICulture property.
Returns
- string
The value of the resource localized for the specified culture. If a best match is not possible,
nullis returned.
Exceptions
- ArgumentNullException
The
nameparameter isnull.- InvalidOperationException
The value of the specified resource is not a string.
- MissingManifestResourceException
No usable set of resources has been found, and there are no neutral culture resources.
ReleaseAllResources()
Tells the ResourceManager to call Close() on all ResourceSet objects and release all resources.
public override void ReleaseAllResources()
ToString()
Returns a string that represents this instance.
public override string ToString()