System.Resources.ResourceSet Class

Assembly: Mscorlib.dll
Namespace: System.Resources
Summary
Stores all the resources localized for one particular culture, ignoring all other cultures, including any fallback rules.
C# Syntax:
[Serializable]
public class ResourceSet : IDisposable
Remarks
The ResourceSet class enumerates over an IResourceReader, loading every name and value, and storing them in a Hashtable. A custom IResourceReader can be used.

See the the conceptual topic at MSDN: designingglobalapplications for details on the default resource file format.



Notes to inheritors: Derived classes of ResourceSet using their own resource reader and writer should override ResourceSet.GetDefaultReader, and ResourceSet.GetDefaultWriter, to provide the appropriate functionality for interpreting the ResourceSet.
See also:
System.Resources Namespace See also:
MSDN: designingglobalapplications

System.Resources.ResourceSet Member List:

Public Constructors
ctor #2 Overloaded:
.ctor(IResourceReader reader)

Creates a new instance of the ResourceSet class using the specified resource reader.
ctor #3 Overloaded:
.ctor(Stream stream)

Creates a new instance of the ResourceSet class using the system default ResourceReader that reads resources from the given stream.
ctor #4 Overloaded:
.ctor(string fileName)

Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.
Public Methods
Close Closes and releases any resources used by this ResourceSet.
Dispose Overloaded:
Dispose()

Disposes of the resources (other than memory) used by the current instance of ResourceSet.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetDefaultReader Returns the preferred resource reader class for this kind of ResourceSet.
GetDefaultWriter Returns the preferred resource writer class for this kind of ResourceSet.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetObject Overloaded:
GetObject(string name)

Searches for a resource object with the specified name.
GetObject Overloaded:
GetObject(string name, bool ignoreCase)

Searches for a resource object with the specified name in a case-insensitive manner, if requested.
GetString Overloaded:
GetString(string name)

Searches for a String resource with the specified name.
GetString Overloaded:
GetString(string name, bool ignoreCase)

Searches for a String resource with the specified name in a case-insensitive manner, if requested.
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.
Protected Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the ResourceSet class with default properties.
Protected Fields
Reader Indicates the IResourceReader used to read the resources.
Table The Hashtable in which the resources are stored.
Protected Methods
Dispose Overloaded:
Dispose(bool disposing)

Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested.
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.
ReadResources Reads all the resources and stores them in a Hashtable indicated in the ResourceSet.Table property.

Hierarchy:


System.Resources.ResourceSet Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the ResourceSet class with default properties.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected ResourceSet();

Return to top


Overloaded ctor #2
Summary
Creates a new instance of the ResourceSet class using the specified resource reader.
C# Syntax:
public ResourceSet(
   IResourceReader reader
);
Parameters:

reader

The reader that will be used.

Exceptions
Exception Type Condition
ArgumentNullException The reader parameter is null.
Remarks
You can use this constructor to support custom resource formats using a user-provided IResourceReader.

Return to top


Overloaded ctor #3
Summary
Creates a new instance of the ResourceSet class using the system default ResourceReader that reads resources from the given stream.
C# Syntax:
public ResourceSet(
   Stream stream
);
Parameters:

stream

The Stream of resources to be read. The stream should refer to an existing resources file.

Exceptions
Exception Type Condition
ArgumentException The stream is not readable.
ArgumentNullException The stream parameter is null.

Return to top


Overloaded ctor #4
Summary
Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.
C# Syntax:
public ResourceSet(
   string fileName
);
Parameters:

fileName

Resource file to read.

Exceptions
Exception Type Condition
ArgumentNullException The fileName parameter is null.

Return to top


Field: Reader
Summary
Indicates the IResourceReader used to read the resources.
C# Syntax:
protected IResourceReader Reader;
See also:
IResourceReader

Return to top


Field: Table
Summary
The Hashtable in which the resources are stored.
C# Syntax:
protected Hashtable Table;
See also:
Hashtable

Return to top


Method: Close()
Summary
Closes and releases any resources used by this ResourceSet.
C# Syntax:
public virtual void Close();
Remarks
All calls to methods on the ResourceSet after a call to this method might fail.

ResourceSet.Close can be safely called multiple times.



Note The current implementation of ResourceSet.Close calls ResourceSet.Dispose (true).

Return to top


Overloaded Method: Dispose()
Summary
Disposes of the resources (other than memory) used by the current instance of ResourceSet.
C# Syntax:
public void Dispose();
Implements:
IDisposable.Dispose
Remarks
Call ResourceSet.Dispose when you are finished using the ResourceSet. The ResourceSet.Dispose method leaves the ResourceSet in an unusable state. After calling ResourceSet.Dispose, you must release all references to the ResourceSet so the memory it was occupying can be reclaimed by garbage collection.

Note The current method is the implementation of IDisposable.Dispose. This implementation calls ResourceSet.Dispose (true).

Return to top


Overloaded Method: Dispose(
   bool disposing
)
Summary
Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested.
C# Syntax:
protected virtual void Dispose(
   bool disposing
);
Parameters:

disposing

Indicates whether the objects contained in the current instance should be explicitly closed.

Remarks
If the dispose parameter is true, the current method frees all the resources associated with it as well as with all objects associated with it. If dispose is false, the current method frees only the resources allocated to it, and ignores any objects associated with it.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~ResourceSet();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetDefaultReader()
Summary
Returns the preferred resource reader class for this kind of ResourceSet.
C# Syntax:
public virtual Type GetDefaultReader();
Return Value:
Returns the Type for the preferred resource reader for this kind of ResourceSet.
Remarks


Notes to inheritors: Derived classes of ResourceSet using their own resource reader should override ResourceSet.GetDefaultReader, and ResourceSet.GetDefaultWriter.
See also:
IResourceReader

Return to top


Method: GetDefaultWriter()
Summary
Returns the preferred resource writer class for this kind of ResourceSet.
C# Syntax:
public virtual Type GetDefaultWriter();
Return Value:
Returns the Type for the preferred resource writer for this kind of ResourceSet.
Remarks


Notes to inheritors: Derived classes of ResourceSet using their own resource reader should override ResourceSet.GetDefaultReader, and ResourceSet.GetDefaultWriter.
See also:
IResourceWriter

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: GetObject(
   string name
)
Summary
Searches for a resource object with the specified name.
C# Syntax:
public virtual object GetObject(
   string name
);
Parameters:

name

Name of the resource to search for.

Return Value:
The requested resource.
Exceptions
Exception Type Condition
ArgumentNullException The name parameter is null.
InvalidOperationException This ResourceSet has been closed.

Return to top


Overloaded Method: GetObject(
   string name,
   bool ignoreCase
)
Summary
Searches for a resource object with the specified name in a case-insensitive manner, if requested.
C# Syntax:
public virtual object GetObject(
   string name,
   bool ignoreCase
);
Parameters:

name

Name of the resource to search for.

ignoreCase

Indicates whether the case of the case of the specified name should be ignored.

Return Value:
The requested resource.
Exceptions
Exception Type Condition
ArgumentNullException The name parameter is null.
InvalidOperationException This ResourceSet has been closed.

Return to top


Overloaded Method: GetString(
   string name
)
Summary
Searches for a String resource with the specified name.
C# Syntax:
public virtual string GetString(
   string name
);
Parameters:

name

Name of the resource to search for.

Return Value:
The value of a resource, if the value is a String.
Exceptions
Exception Type Condition
ArgumentNullException The name parameter is null.
InvalidOperationException The resource with the specified name is not a String or the current ResourceSet has been closed.

Return to top


Overloaded Method: GetString(
   string name,
   bool ignoreCase
)
Summary
Searches for a String resource with the specified name in a case-insensitive manner, if requested.
C# Syntax:
public virtual string GetString(
   string name,
   bool ignoreCase
);
Parameters:

name

Name of the resource to search for.

ignoreCase

Indicates whether the case of the case of the specified name should be ignored.

Return Value:
The value of a resource, if the value is a String.
Exceptions
Exception Type Condition
ArgumentNullException The name parameter is null.
InvalidOperationException The resource with the specified name is not a String or the current ResourceSet has been closed.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ReadResources()
Summary
Reads all the resources and stores them in a Hashtable indicated in the ResourceSet.Table property.
C# Syntax:
protected virtual void ReadResources();
Remarks


Notes to inheritors: Derived classes of ResourceSet should explicitly call ResourceSet.ReadResources to load all the resources from the IResourceReader into ResourceSet.Table, generally either in the constructor or lazily on the first call to either ResourceSet.GetString or ResourceSet.GetObject. However, if your resource set and IResourceReader already have information about each other and have a more efficient way to load just a few select resources, this step can be skipped. To minimize working set, write your resource set in such a way that it queries your IResourceReader for only the resource values requested by your application.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.