ResourceSet ResourceSet ResourceSet ResourceSet Class

定义

存储已针对某个特定区域性进行了本地化的所有资源,忽略所有其他区域性(包括任何代用规则)。Stores all the resources localized for one particular culture, ignoring all other cultures, including any fallback rules.

public ref class ResourceSet : IDisposable, System::Collections::IEnumerable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class ResourceSet : IDisposable, System.Collections.IEnumerable
type ResourceSet = class
    interface IDisposable
    interface IEnumerable
Public Class ResourceSet
Implements IDisposable, IEnumerable
继承
ResourceSetResourceSetResourceSetResourceSet
派生
属性
实现

注解

重要

使用不受信任的数据调用此类中的方法存在安全风险。Calling methods from this class with untrusted data is a security risk. 仅使用受信任的数据调用此类中的方法。Call the methods from this class only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

ResourceSet类枚举IResourceReader,加载每个名称和值,并将它们存储在HashtableThe ResourceSet class enumerates over an IResourceReader, loading every name and value, and storing them in a Hashtable. 自定义IResourceReader可用。A custom IResourceReader can be used.

可以实例化ResourceSet对象,表示特定区域性的资源通过调用ResourceManager.GetResourceSet方法。You can instantiate a ResourceSet object that represents the resources of a specific culture by calling the ResourceManager.GetResourceSet method.

重要

此类型实现IDisposable接口。This type implements the IDisposable interface. 在使用完类型后,您应直接或间接释放类型。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接释放类型,调用其Dispose中的方法try / catch块。To dispose of the type directly, call its Dispose method in a try/catch block. 若要间接释放类型,请使用 using(在 C# 中)或 Using(在 Visual Basic 中)等语言构造。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 有关详细信息,请参阅中的"使用对象实现 IDisposable"一节IDisposable接口主题。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

继承者说明

派生类的ResourceSet使用其自己的资源读取器和编写器应重写GetDefaultReader(),和GetDefaultWriter()、 用于解释资源集提供适当的功能。Derived classes of ResourceSet that use their own resource reader and writer should override GetDefaultReader(), and GetDefaultWriter(), to provide the appropriate functionality for interpreting the resource set.

构造函数

ResourceSet() ResourceSet() ResourceSet() ResourceSet()

使用默认属性初始化 ResourceSet 类的新实例。Initializes a new instance of the ResourceSet class with default properties.

ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader) ResourceSet(IResourceReader)

使用指定的资源阅读器创建 ResourceSet 类的新实例。Creates a new instance of the ResourceSet class using the specified resource reader.

ResourceSet(Stream) ResourceSet(Stream) ResourceSet(Stream) ResourceSet(Stream)

使用从给定流中读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that reads resources from the given stream.

ResourceSet(String) ResourceSet(String) ResourceSet(String) ResourceSet(String)

使用从给定文件打开并读取资源的系统默认的 ResourceSet 来创建 ResourceReader 类的新实例。Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.

字段

Reader Reader Reader Reader

指示用于读取资源的 IResourceReaderIndicates the IResourceReader used to read the resources.

Table Table Table Table

存储资源的 HashtableThe Hashtable in which the resources are stored.

方法

Close() Close() Close() Close()

通过此 ResourceSet 来关闭和释放所有资源。Closes and releases any resources used by this ResourceSet.

Dispose() Dispose() Dispose() Dispose()

处置由 ResourceSet 的当前实例使用的资源(内存除外)。Disposes of the resources (other than memory) used by the current instance of ResourceSet.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放与当前实例关联的资源(内存除外),并关闭内部托管对象(如果请求这样做)。Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDefaultReader() GetDefaultReader() GetDefaultReader() GetDefaultReader()

返回此类 ResourceSet 的首选资源读取器类。Returns the preferred resource reader class for this kind of ResourceSet.

GetDefaultWriter() GetDefaultWriter() GetDefaultWriter() GetDefaultWriter()

返回此类 ResourceSet 的首选资源编写器类。Returns the preferred resource writer class for this kind of ResourceSet.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回 IDictionaryEnumerator,它可以循环访问 ResourceSetReturns an IDictionaryEnumerator that can iterate through the ResourceSet.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetObject(String) GetObject(String) GetObject(String) GetObject(String)

搜索具有指定名称的资源对象。Searches for a resource object with the specified name.

GetObject(String, Boolean) GetObject(String, Boolean) GetObject(String, Boolean) GetObject(String, Boolean)

如果请求的话,按照不区分大小写的方式搜索具有指定名称的资源对象。Searches for a resource object with the specified name in a case-insensitive manner, if requested.

GetString(String) GetString(String) GetString(String) GetString(String)

搜索具有指定名称的 String 资源。Searches for a String resource with the specified name.

GetString(String, Boolean) GetString(String, Boolean) GetString(String, Boolean) GetString(String, Boolean)

如果请求的话,按照不区分大小写的方式搜索具有指定名称的 String 资源。Searches for a String resource with the specified name in a case-insensitive manner, if requested.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ReadResources() ReadResources() ReadResources() ReadResources()

读取所有资源,并将它们存储在 Hashtable 属性中指示的 Table 中。Reads all the resources and stores them in a Hashtable indicated in the Table property.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

返回一个 IEnumerator 对象,以避免与 Dispose 之间出现争用情况。Returns an IEnumerator object to avoid a race condition with Dispose. 不应直接在您的代码中使用此成员。This member is not intended to be used directly from your code.

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于