ResXResourceReader Class
Enumerates XML resource (.resx) files and streams, and reads the sequential resource name and value pairs.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The ResXResourceReader type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ResXResourceReader(Stream) | Initializes a new instance of the ResXResourceReader class for the specified stream. |
![]() | ResXResourceReader(String) | Initializes a new instance of the ResXResourceReader class for the specified resource file. |
![]() | ResXResourceReader(TextReader) | Initializes a new instance of the ResXResourceReader class for the specified TextReader. |
![]() | ResXResourceReader(Stream, ITypeResolutionService) | Initializes a new instance of the ResXResourceReader class using an input stream and a type resolution service. |
![]() | ResXResourceReader(Stream, array<AssemblyName>) | Initializes a new instance of the ResXResourceReader class using a stream and an array of assembly names. |
![]() | ResXResourceReader(String, ITypeResolutionService) | Initializes a new instance of the ResXResourceReader class using a file name and a type resolution service. |
![]() | ResXResourceReader(String, array<AssemblyName>) | Initializes a new instance of the ResXResourceReader class using an XML resource file name and an array of assembly names. |
![]() | ResXResourceReader(TextReader, ITypeResolutionService) | Initializes a new instance of the ResXResourceReader class using a text stream reader and a type resolution service. |
![]() | ResXResourceReader(TextReader, array<AssemblyName>) | Initializes a new instance of the ResXResourceReader class using a TextReader object and an array of assembly names. |
| Name | Description | |
|---|---|---|
![]() | BasePath | Gets or sets the base path for the relative file path specified in a ResXFileRef object. |
![]() | UseResXDataNodes | Gets or sets a value indicating whether ResXDataNode objects are returned when reading the current XML resource file or stream. |
| Name | Description | |
|---|---|---|
![]() | Close | Releases all resources used by the ResXResourceReader. |
![]() | Dispose | Releases the unmanaged resources used by the ResXResourceReader and optionally releases the managed resources. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | This member overrides the Finalize method. (Overrides Object::Finalize().) |
![]() ![]() | FromFileContents(String) | Creates a new ResXResourceReader object and initializes it to read a string whose contents are in the form of an XML resource file. |
![]() ![]() | FromFileContents(String, ITypeResolutionService) | Infrastructure. Creates a new ResXResourceReader object and initializes it to read a string whose contents are in the form of an XML resource file, and to use an ITypeResolutionService object to resolve type names specified in a resource. |
![]() ![]() | FromFileContents(String, array<AssemblyName>) | Infrastructure. Creates a new ResXResourceReader object and initializes it to read a string whose contents are in the form of an XML resource file, and to use an array of AssemblyName objects to resolve type names specified in a resource. |
![]() | GetEnumerator | Returns an enumerator for the current ResXResourceReader object. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetMetadataEnumerator | Provides a dictionary enumerator that can retrieve the design-time properties from the current XML resource file or stream. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | AsParallel | Enables parallelization of a query. (Defined by ParallelEnumerable.) |
![]() | AsQueryable | Converts an IEnumerable to an IQueryable. (Defined by Queryable.) |
![]() | Cast<TResult> | Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.) |
![]() | OfType<TResult> | Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.) |
| Name | Description | |
|---|---|---|
![]() ![]() | IDisposable::Dispose | Infrastructure. Releases the unmanaged resources used by the ResXResourceReader and optionally releases the managed resources. For a description of this member, see IDisposable::Dispose. |
![]() ![]() | IEnumerable::GetEnumerator | Infrastructure. Returns an enumerator for the current ResXResourceReader object. For a description of this member, see IEnumerable::GetEnumerator. |
The ResXResourceReader provides a default implementation of the IResourceReader interface that reads resource information in an XML format. To read resource information from a binary resource format, use ResourceReader.
You can use resource readers to read resource name and value pairs from .resx files. The resources can be enumerated by traversing the IDictionaryEnumerator returned by the GetEnumerator method. You can use the methods provided by the IDictionaryEnumerator to advance to the next resource and read the name and value of each resource in the .resx file.
For more information on the format of a .resx file, see Resources in .resx File Format.
Note |
|---|
IEnumerable::GetEnumerator returns an IEnumerator not IDictionaryEnumerator. |
Note |
|---|
This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands. |
The following example demonstrates how to use a ResXResourceReader to iterate through the resources in a .resx file. First, the ResXResourceReader rsxr is created for the file items.resx. Next, the GetEnumerator method is used to create an IDictionaryEnumerator to iterate through the resources and display the contents to the console.
#using <system.windows.forms.dll> #using <System.dll> using namespace System; using namespace System::Resources; using namespace System::Collections; void main() { // Create a ResXResourceReader for the file items.resx. ResXResourceReader^ rsxr = gcnew ResXResourceReader( "items.resx" ); // Iterate through the resources and display the contents to the console. IEnumerator^ myEnum = rsxr->GetEnumerator(); while ( myEnum->MoveNext() ) { DictionaryEntry^ d = safe_cast<DictionaryEntry^>(myEnum->Current); Console::WriteLine( "{0}:\t {1}", d->Key, d->Value ); } //Close the reader. rsxr->Close(); }
- SecurityAction::LinkDemand
for full trust for the immediate caller. This member cannot be used by partially trusted code.
- SecurityAction::InheritanceDemand
for full trust for inheritors. This class cannot be inherited by partially trusted code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
