mscorlib(4.0.0.0) API with additions
System.Resources.ResourceManager Class Reference

Represents a resource manager that provides convenient access to culture-specific resources at run time. Security Note: Calling methods in this class with untrusted data is a security risk. Call the methods in the class only with trusted data. For more information, see Untrusted Data Security Risks. More...

Inheritance diagram for System.Resources.ResourceManager:
[legend]
Collaboration diagram for System.Resources.ResourceManager:
[legend]

Public Member Functions

 ResourceManager (string baseName, Assembly assembly)
 Initializes a new instance of the T:System.Resources.ResourceManager class that looks up resources contained in files with the specified root name in the given assembly. More...
 
 ResourceManager (string baseName, Assembly assembly, Type usingResourceSet)
 Initializes a new instance of the T:System.Resources.ResourceManager class that uses a specified T:System.Resources.ResourceSet class to look up resources contained in files with the specified root name in the given assembly. More...
 
 ResourceManager (Type resourceSource)
 Initializes a new instance of the T:System.Resources.ResourceManager class that looks up resources in satellite assemblies based on information from the specified type object. More...
 
virtual void ReleaseAllResources ()
 Tells the resource manager to call the M:System.Resources.ResourceSet.Close method on all T:System.Resources.ResourceSet objects and release all resources. More...
 
virtual ResourceSet GetResourceSet (CultureInfo culture, bool createIfNotExists, bool tryParents)
 Retrieves the resource set for a particular culture. More...
 
virtual string GetString (string name)
 Returns the value of the specified string resource. More...
 
virtual string GetString (string name, CultureInfo culture)
 Returns the value of the string resource localized for the specified culture. More...
 
virtual object GetObject (string name)
 Returns the value of the specified non-string resource. More...
 
virtual object GetObject (string name, CultureInfo culture)
 Gets the value of the specified non-string resource localized for the specified culture. More...
 
UnmanagedMemoryStream GetStream (string name)
 Returns an unmanaged memory stream object from the specified resource. More...
 
UnmanagedMemoryStream GetStream (string name, CultureInfo culture)
 Returns an unmanaged memory stream object from the specified resource, using the specified culture. More...
 

Static Public Member Functions

static ResourceManager CreateFileBasedResourceManager (string baseName, string resourceDir, Type usingResourceSet)
 Returns a T:System.Resources.ResourceManager object that searches a specific directory instead of an assembly manifest for resources. More...
 

Public Attributes

virtual string BaseName => BaseNameField
 Gets the root name of the resource files that the T:System.Resources.ResourceManager searches for resources. More...
 

Static Public Attributes

static readonly int MagicNumber = -1091581234
 Holds the number used to identify resource files. More...
 
static readonly int HeaderVersionNumber = 1
 Specifies the version of resource file headers that the current implementation of T:System.Resources.ResourceManager can interpret and produce. More...
 

Protected Member Functions

 ResourceManager ()
 Initializes a new instance of the T:System.Resources.ResourceManager class with default values. More...
 
virtual string GetResourceFileName (CultureInfo culture)
 Generates the name of the resource file for the given T:System.Globalization.CultureInfo object. More...
 
virtual ResourceSet InternalGetResourceSet (CultureInfo culture, bool createIfNotExists, bool tryParents)
 Provides the implementation for finding a resource set. More...
 

Static Protected Member Functions

static Version GetSatelliteContractVersion (Assembly a)
 Returns the version specified by the T:System.Resources.SatelliteContractVersionAttribute attribute in the given assembly. More...
 
static CultureInfo GetNeutralResourcesLanguage (Assembly a)
 Returns culture-specific information for the main assembly's default resources by retrieving the value of the T:System.Resources.NeutralResourcesLanguageAttribute attribute on a specified assembly. More...
 

Protected Attributes

string BaseNameField
 Specifies the root name of the resource files that the T:System.Resources.ResourceManager searches for resources. More...
 
Hashtable ResourceSets
 Contains a T:System.Collections.Hashtable that returns a mapping from cultures to T:System.Resources.ResourceSet objects. More...
 
Assembly MainAssembly
 Specifies the main assembly that contains the resources. More...
 

Properties

virtual bool IgnoreCase [get, set]
 Gets or sets a value that indicates whether the resource manager allows case-insensitive resource lookups in the M:System.Resources.ResourceManager.GetString(System.String) and M:System.Resources.ResourceManager.GetObject(System.String) methods. More...
 
virtual Type ResourceSetType [get]
 Gets the type of the resource set object that the resource manager uses to construct a T:System.Resources.ResourceSet object. More...
 
UltimateResourceFallbackLocation FallbackLocation [get, set]
 Gets or sets the location from which to retrieve default fallback resources. More...
 

Detailed Description

Represents a resource manager that provides convenient access to culture-specific resources at run time. Security Note: Calling methods in this class with untrusted data is a security risk. Call the methods in the class only with trusted data. For more information, see Untrusted Data Security Risks.

Definition at line 21 of file ResourceManager.cs.

Constructor & Destructor Documentation

◆ ResourceManager() [1/4]

System.Resources.ResourceManager.ResourceManager ( )
protected

Initializes a new instance of the T:System.Resources.ResourceManager class with default values.

Definition at line 264 of file ResourceManager.cs.

◆ ResourceManager() [2/4]

System.Resources.ResourceManager.ResourceManager ( string  baseName,
Assembly  assembly 
)

Initializes a new instance of the T:System.Resources.ResourceManager class that looks up resources contained in files with the specified root name in the given assembly.

Parameters
baseNameThe root name of the resource file without its extension but including any fully qualified namespace name. For example, the root name for the resource file named MyApplication.MyResource.en-US.resources is MyApplication.MyResource.
assemblyThe main assembly for the resources.
Exceptions
T:System.ArgumentNullExceptionThe baseName or assembly parameter is null.

Definition at line 313 of file ResourceManager.cs.

◆ ResourceManager() [3/4]

System.Resources.ResourceManager.ResourceManager ( string  baseName,
Assembly  assembly,
Type  usingResourceSet 
)

Initializes a new instance of the T:System.Resources.ResourceManager class that uses a specified T:System.Resources.ResourceSet class to look up resources contained in files with the specified root name in the given assembly.

Parameters
baseNameThe root name of the resource file without its extension but including any fully qualified namespace name. For example, the root name for the resource file named MyApplication.MyResource.en-US.resources is MyApplication.MyResource.
assemblyThe main assembly for the resources.
usingResourceSetThe type of the custom T:System.Resources.ResourceSet to use. If null, the default runtime T:System.Resources.ResourceSet object is used.
Exceptions
T:System.ArgumentExceptionusingResourceset is not a derived class of T:System.Resources.ResourceSet.
T:System.ArgumentNullExceptionThe baseName or assembly parameter is null.

Definition at line 347 of file ResourceManager.cs.

◆ ResourceManager() [4/4]

System.Resources.ResourceManager.ResourceManager ( Type  resourceSource)

Initializes a new instance of the T:System.Resources.ResourceManager class that looks up resources in satellite assemblies based on information from the specified type object.

Parameters
resourceSourceA type from which the resource manager derives all information for finding .resources files.
Exceptions
T:System.ArgumentNullExceptionThe resourceSource parameter is null.

Definition at line 381 of file ResourceManager.cs.

Member Function Documentation

◆ CreateFileBasedResourceManager()

static ResourceManager System.Resources.ResourceManager.CreateFileBasedResourceManager ( string  baseName,
string  resourceDir,
Type  usingResourceSet 
)
static

Returns a T:System.Resources.ResourceManager object that searches a specific directory instead of an assembly manifest for resources.

Parameters
baseNameThe root name of the resources. For example, the root name for the resource file named "MyResource.en-US.resources" is "MyResource".
resourceDirThe name of the directory to search for the resources. resourceDir can be an absolute path or a relative path from the application directory.
usingResourceSetThe type of the custom T:System.Resources.ResourceSet to use. If null, the default runtime T:System.Resources.ResourceSet object is used.
Returns
A new instance of a resource manager that searches the specified directory instead of an assembly manifest for resources.
Exceptions
T:System.ArgumentNullExceptionThe baseName or resourceDir parameter is null.

Definition at line 521 of file ResourceManager.cs.

◆ GetNeutralResourcesLanguage()

static CultureInfo System.Resources.ResourceManager.GetNeutralResourcesLanguage ( Assembly  a)
staticprotected

Returns culture-specific information for the main assembly's default resources by retrieving the value of the T:System.Resources.NeutralResourcesLanguageAttribute attribute on a specified assembly.

Parameters
aThe assembly for which to return culture-specific information.
Returns
The culture from the T:System.Resources.NeutralResourcesLanguageAttribute attribute, if found; otherwise, the invariant culture.

Definition at line 787 of file ResourceManager.cs.

◆ GetObject() [1/2]

virtual object System.Resources.ResourceManager.GetObject ( string  name)
virtual

Returns the value of the specified non-string resource.

Parameters
nameThe name of the resource to get.
Returns
The value of the resource localized for the caller's current culture settings. If an appropriate resource set exists but name cannot be found, the method returns null.
Exceptions
T:System.ArgumentNullExceptionThe name parameter is null.
T:System.Resources.MissingManifestResourceExceptionNo usable set of localized resources has been found, and there are no default culture resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 1038 of file ResourceManager.cs.

◆ GetObject() [2/2]

virtual object System.Resources.ResourceManager.GetObject ( string  name,
CultureInfo  culture 
)
virtual

Gets the value of the specified non-string resource localized for the specified culture.

Parameters
nameThe name of the resource to get.
cultureThe culture for which the resource is localized. If the resource is not localized for this culture, the resource manager uses fallback rules to locate an appropriate resource.If this value is null, the T:System.Globalization.CultureInfo object is obtained by using the P:System.Globalization.CultureInfo.CurrentUICulture property.
Returns
The value of the resource, localized for the specified culture. If an appropriate resource set exists but name cannot be found, the method returns null.
Exceptions
T:System.ArgumentNullExceptionThe name parameter is null.
T:System.Resources.MissingManifestResourceExceptionNo usable set of resources have been found, and there are no default culture resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 1050 of file ResourceManager.cs.

◆ GetResourceFileName()

virtual string System.Resources.ResourceManager.GetResourceFileName ( CultureInfo  culture)
protectedvirtual

Generates the name of the resource file for the given T:System.Globalization.CultureInfo object.

Parameters
cultureThe culture object for which a resource file name is constructed.
Returns
The name that can be used for a resource file for the given T:System.Globalization.CultureInfo object.

Definition at line 529 of file ResourceManager.cs.

◆ GetResourceSet()

virtual ResourceSet System.Resources.ResourceManager.GetResourceSet ( CultureInfo  culture,
bool  createIfNotExists,
bool  tryParents 
)
virtual

Retrieves the resource set for a particular culture.

Parameters
cultureThe culture whose resources are to be retrieved.
createIfNotExiststrue to load the resource set, if it has not been loaded yet; otherwise, false.
tryParentstrue to use resource fallback to load an appropriate resource if the resource set cannot be found; false to bypass the resource fallback process. (See the Remarks section.)
Returns
The resource set for the specified culture.
Exceptions
T:System.ArgumentNullExceptionThe culture parameter is null.
T:System.Resources.MissingManifestResourceExceptiontryParents is true, no usable set of resources has been found, and there are no default culture resources.

Definition at line 596 of file ResourceManager.cs.

◆ GetSatelliteContractVersion()

static Version System.Resources.ResourceManager.GetSatelliteContractVersion ( Assembly  a)
staticprotected

Returns the version specified by the T:System.Resources.SatelliteContractVersionAttribute attribute in the given assembly.

Parameters
aThe assembly to check for the T:System.Resources.SatelliteContractVersionAttribute attribute.
Returns
The satellite contract version of the given assembly, or null if no version was found.
Exceptions
T:System.ArgumentExceptionThe T:System.Version found in the assembly a is invalid.
T:System.ArgumentNullExceptiona is null.

Definition at line 738 of file ResourceManager.cs.

◆ GetStream() [1/2]

UnmanagedMemoryStream System.Resources.ResourceManager.GetStream ( string  name)

Returns an unmanaged memory stream object from the specified resource.

Parameters
nameThe name of a resource.
Returns
An unmanaged memory stream object that represents a resource .
Exceptions
T:System.InvalidOperationExceptionThe value of the specified resource is not a T:System.IO.MemoryStream object.
T:System.ArgumentNullExceptionname is null.
T:System.Resources.MissingManifestResourceExceptionNo usable set of resources is found, and there are no default resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 1134 of file ResourceManager.cs.

◆ GetStream() [2/2]

UnmanagedMemoryStream System.Resources.ResourceManager.GetStream ( string  name,
CultureInfo  culture 
)

Returns an unmanaged memory stream object from the specified resource, using the specified culture.

Parameters
nameThe name of a resource.
cultureAn object that specifies the culture to use for the resource lookup. If culture is null, the culture for the current thread is used.
Returns
An unmanaged memory stream object that represents a resource.
Exceptions
T:System.InvalidOperationExceptionThe value of the specified resource is not a T:System.IO.MemoryStream object.
T:System.ArgumentNullExceptionname is null.
T:System.Resources.MissingManifestResourceExceptionNo usable set of resources is found, and there are no default resources. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 1149 of file ResourceManager.cs.

◆ GetString() [1/2]

virtual string System.Resources.ResourceManager.GetString ( string  name)
virtual

Returns the value of the specified string resource.

Parameters
nameThe name of the resource to retrieve.
Returns
The value of the resource localized for the caller's current UI culture, or null if name cannot be found in a resource set.
Exceptions
T:System.ArgumentNullExceptionThe name parameter is null.
T:System.InvalidOperationExceptionThe value of the specified resource is not a string.
T:System.Resources.MissingManifestResourceExceptionNo usable set of resources has been found, and there are no resources for the default culture. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 946 of file ResourceManager.cs.

◆ GetString() [2/2]

virtual string System.Resources.ResourceManager.GetString ( string  name,
CultureInfo  culture 
)
virtual

Returns the value of the string resource localized for the specified culture.

Parameters
nameThe name of the resource to retrieve.
cultureAn object that represents the culture for which the resource is localized.
Returns
The value of the resource localized for the specified culture, or null if name cannot be found in a resource set.
Exceptions
T:System.ArgumentNullExceptionThe name parameter is null.
T:System.InvalidOperationExceptionThe value of the specified resource is not a string.
T:System.Resources.MissingManifestResourceExceptionNo usable set of resources has been found, and there are no resources for a default culture. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.
T:System.Resources.MissingSatelliteAssemblyExceptionThe default culture's resources reside in a satellite assembly that could not be found. For information about how to handle this exception, see the "Handling MissingManifestResourceException and MissingSatelliteAssemblyException Exceptions" section in the T:System.Resources.ResourceManager class topic.

Definition at line 960 of file ResourceManager.cs.

◆ InternalGetResourceSet()

virtual ResourceSet System.Resources.ResourceManager.InternalGetResourceSet ( CultureInfo  culture,
bool  createIfNotExists,
bool  tryParents 
)
protectedvirtual

Provides the implementation for finding a resource set.

Parameters
cultureThe culture object to look for.
createIfNotExiststrue to load the resource set, if it has not been loaded yet; otherwise, false.
tryParentstrue to check parent T:System.Globalization.CultureInfo objects if the resource set cannot be loaded; otherwise, false.
Returns
The specified resource set.
Exceptions
T:System.Resources.MissingManifestResourceExceptionThe main assembly does not contain a .resources file, which is required to look up a resource.
T:System.ExecutionEngineExceptionThere was an internal error in the runtime.
T:System.Resources.MissingSatelliteAssemblyExceptionThe satellite assembly associated with culture could not be located.

Definition at line 641 of file ResourceManager.cs.

◆ ReleaseAllResources()

virtual void System.Resources.ResourceManager.ReleaseAllResources ( )
virtual

Tells the resource manager to call the M:System.Resources.ResourceSet.Close method on all T:System.Resources.ResourceSet objects and release all resources.

Definition at line 483 of file ResourceManager.cs.

Member Data Documentation

◆ BaseName

virtual string System.Resources.ResourceManager.BaseName => BaseNameField

Gets the root name of the resource files that the T:System.Resources.ResourceManager searches for resources.

Returns
The root name of the resource files that the T:System.Resources.ResourceManager searches for resources.

Definition at line 212 of file ResourceManager.cs.

◆ BaseNameField

string System.Resources.ResourceManager.BaseNameField
protected

Specifies the root name of the resource files that the T:System.Resources.ResourceManager searches for resources.

Definition at line 123 of file ResourceManager.cs.

◆ HeaderVersionNumber

readonly int System.Resources.ResourceManager.HeaderVersionNumber = 1
static

Specifies the version of resource file headers that the current implementation of T:System.Resources.ResourceManager can interpret and produce.

Definition at line 179 of file ResourceManager.cs.

◆ MagicNumber

readonly int System.Resources.ResourceManager.MagicNumber = -1091581234
static

Holds the number used to identify resource files.

Definition at line 176 of file ResourceManager.cs.

◆ MainAssembly

Assembly System.Resources.ResourceManager.MainAssembly
protected

Specifies the main assembly that contains the resources.

Definition at line 135 of file ResourceManager.cs.

◆ ResourceSets

Hashtable System.Resources.ResourceManager.ResourceSets
protected

Contains a T:System.Collections.Hashtable that returns a mapping from cultures to T:System.Resources.ResourceSet objects.

Definition at line 127 of file ResourceManager.cs.

Property Documentation

◆ FallbackLocation

UltimateResourceFallbackLocation System.Resources.ResourceManager.FallbackLocation
getsetprotected

Gets or sets the location from which to retrieve default fallback resources.

Returns
One of the enumeration values that specifies where the resource manager can look for fallback resources.

Definition at line 246 of file ResourceManager.cs.

◆ IgnoreCase

virtual bool System.Resources.ResourceManager.IgnoreCase
getset

Gets or sets a value that indicates whether the resource manager allows case-insensitive resource lookups in the M:System.Resources.ResourceManager.GetString(System.String) and M:System.Resources.ResourceManager.GetObject(System.String) methods.

Returns
true to ignore case during resource lookup; otherwise, false.

Definition at line 218 of file ResourceManager.cs.

◆ ResourceSetType

virtual Type System.Resources.ResourceManager.ResourceSetType
get

Gets the type of the resource set object that the resource manager uses to construct a T:System.Resources.ResourceSet object.

Returns
The type of the resource set object that the resource manager uses to construct a T:System.Resources.ResourceSet object.

Definition at line 232 of file ResourceManager.cs.


The documentation for this class was generated from the following file: