public sealed class ResourceReader : IResourceReader, IEnumerable, IDisposable
|
You can use resource readers to read resource name and resource value pairs from .resources files. The resources can be enumerated by traversing the IDictionaryEnumerator returned by the ResourceReader.GetEnumerator method. The methods provided by the IDictionaryEnumerator are used to advance to the next resource and read the name and value of each resource in the .resources file.
using System; using System.Resources; using System.Collections; public class ReadResources { public static void Main(string[] args) { // Opens a resource reader and gets an enumerator from it. IResourceReader reader = new ResourceReader("myResources.resources"); IDictionaryEnumerator en = reader.GetEnumerator(); // Goes through the enumerator, printing out the key and value pairs. while (en.MoveNext()) { Console.WriteLine(); Console.WriteLine("Name: {0}", en.Key); Console.WriteLine("Value: {0}", en.Value); } reader.Close(); } }
ctor #1 | Overloaded:.ctor(Stream stream) Initializes a new instance of the ResourceReader class for the specified stream. |
ctor #2 | Overloaded:.ctor(string fileName) Initializes a new instance of the ResourceReader class for the specified resource file. |
Close | Releases all operating system resources associated with this ResourceReader. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetEnumerator | Returns an enumerator for this ResourceReader. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
IEnumerable.GetEnumerator | Returns an enumerator for this ResourceReader. |
IDisposable.Dispose | Releases the resources used by the ResourceReader. |
Hierarchy:
public ResourceReader( |
stream
Exception Type | Condition |
---|---|
ArgumentException | The stream is not readable. |
ArgumentNullException | The stream parameter is null. |
IOException | An I/O error has occured while accessing stream. |
public ResourceReader( |
fileName
Exception Type | Condition |
---|---|
ArgumentNullException | The fileName parameter is null. |
FileNotFoundException | The file cannot be found. |
IOException | An I/O error has occured. |
public void Close(); |
~ResourceReader(); |
public IDictionaryEnumerator GetEnumerator(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The reader has already been closed, and thus cannot be accessed. |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
IEnumerator IEnumerable.GetEnumerator(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The reader has already been closed, and thus cannot be accessed. |
void IDisposable.Dispose(); |
public virtual string ToString(); |