ResourceSet 類別

定義

儲存針對某個文化特性並忽略其他所有文化特性進行當地語系化的所有資源,包括任何後援規則。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
繼承
ResourceSet
衍生
屬性
實作

備註

重要

使用不信任的資料呼叫此類別的方法,會造成安全性上的風險。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.

類別會列舉IResourceReader、載入每個名稱和值, 並將Hashtable它們儲存在中。 ResourceSetThe 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. 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。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的資源讀取器和寫入器的衍生類別, 應該覆GetDefaultWriter()GetDefaultReader()、和, 以提供適當的功能來解讀資源集。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 類別的新執行個體。Initializes a new instance of the ResourceSet class with default properties.

ResourceSet(IResourceReader)

使用指定的資源讀取器來建立 ResourceSet 類別的新執行個體。Creates a new instance of the ResourceSet class using the specified resource reader.

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,來建立 ResourceReader 類別的新執行個體。Creates a new instance of the ResourceSet class using the system default ResourceReader that opens and reads resources from the given file.

欄位

Reader

表示用來讀取資源的 IResourceReaderIndicates the IResourceReader used to read the resources.

Table

用來儲存資源的 HashtableThe Hashtable in which the resources are stored.

方法

Close()

關閉並釋放這個 ResourceSet 所使用的任何資源。Closes and releases any resources used by this ResourceSet.

Dispose()

處置 ResourceSet 之目前執行個體所使用的資源 (除了記憶體之外)。Disposes of the resources (other than memory) used by the current instance of ResourceSet.

Dispose(Boolean)

釋放與目前執行個體關聯的資源 (除了記憶體以外),如果要求的話,請關閉內部 Managed 物件。Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetDefaultReader()

傳回這種 ResourceSet 較佳的資源讀取器類別。Returns the preferred resource reader class for this kind of ResourceSet.

GetDefaultWriter()

傳回這種 ResourceSet 較佳的資源寫入器類別。Returns the preferred resource writer class for this kind of ResourceSet.

GetEnumerator()

傳回可以逐一查看 IDictionaryEnumeratorResourceSetReturns an IDictionaryEnumerator that can iterate through the ResourceSet.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetObject(String)

以指定的名稱搜尋資源物件。Searches for a resource object with the specified name.

GetObject(String, Boolean)

如果要求的話,以不區分大小寫的指定名稱搜尋資源物件。Searches for a resource object with the specified name in a case-insensitive manner, if requested.

GetString(String)

以指定的名稱搜尋 String 資源。Searches for a String resource with the specified name.

GetString(String, Boolean)

如果要求的話,以不區分大小寫的指定名稱搜尋 String 資源。Searches for a String resource with the specified name in a case-insensitive manner, if requested.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ReadResources()

讀取所有資源,並將它們儲存在 Hashtable 屬性指示的 Table 中。Reads all the resources and stores them in a Hashtable indicated in the Table property.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

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)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於