XamlReader 類別

定義

針對會使用 XAML 輸入來產生 XAML 節點資料流的類別,提供基底定義。Provides base definitions for classes that consume XAML input and produce XAML node streams.

public ref class XamlReader abstract : IDisposable
public abstract class XamlReader : IDisposable
type XamlReader = class
    interface IDisposable
Public MustInherit Class XamlReader
Implements IDisposable
繼承
XamlReader
衍生
實作

備註

XamlReader是抽象類別, 並不會提供具有所有成員之作用中結果的實作為或定義。XamlReader is an abstract class and does not provide implementations or definitions that have a working result for all members. 在中XamlReader有執行的成員, 會在該成員的備註中注明。Members that do have an implementation in XamlReader are noted in the remarks for that member. 具體而言XamlReader , 有數個必須實作為的抽象成員, 以及數個虛擬成員。Specifically, XamlReader has several abstract members that must be implemented, and several virtual members.

, ReadSubtreeSkip每個成員都提供適用于大部分情況的預設實值。Of the virtual members, ReadSubtree and Skip each provide a default implementation that is appropriate for most cases. 不過, 和ReadSubtree Skip預設的實作為相依于執行 XAML 讀取器的其他預期行為, 特別是依賴Read覆寫。However, the ReadSubtree and Skip default implementations rely on other expected behavior of the implementing XAML reader; in particular, they rely on the Read override. Dispose也是具有可運作之預設實作為的虛擬成員。Dispose is also a virtual member that has a working default implementation.

下列兩個類別是 .NET Framework XAML 服務和 system.string 元件中最相關且實用的衍生類別:The following two classes are the most relevant and practical derived classes in .NET Framework XAML Services and the System.Xaml assembly:

  • XamlObjectReader, 它會讀取物件圖形, 例如在執行時間時, 應用程式的使用中物件圖形。XamlObjectReader, which reads an object graph, such as the active object graph of an application at run time.

  • XamlXmlReader, 它會使用將檔案載入為媒介協助程式類別的一般XmlReader , 以 XML 文字檔的形式讀取 XAML。XamlXmlReader, which reads XAML in the form of a XML text file by using a general XmlReader that loads the file as an intermediary helper class.

其他架構的其他 XAML 讀取器Baml2006Reader包括XamlDebuggerXmlReader和。Other XAML readers from other frameworks include Baml2006Reader and XamlDebuggerXmlReader.

XamlReader與和設計XmlReader原則不同, XamlReader因為沒有傳回基礎Create預設 XAML 讀取器的方法。 XML 文件物件模型 (DOM)XML Document Object Model (DOM)XamlReader differs from XML 文件物件模型 (DOM)XML Document Object Model (DOM) and XmlReader design principles because XamlReader does not have a Create method to return underlying default XAML reader implementations. 您必須藉由呼叫其函式或其他類別特定的協助程式 Api, 以具現化特定的衍生 XAML 讀取器類別。You must instead instantiate specific derived XAML reader classes by calling their constructors or other class-specific helper APIs.

子樹讀取器Subtree Readers

在大部分的情況下, 您XamlReader會在衍生自XamlReader的特定 XAML 讀取器類別內容中呼叫 API。For the most part, you call XamlReader API in the context of specific XAML reader classes that derive from XamlReader. 不過, 在一個特定案例中, 您XamlReader會在實際的 XAML 讀取器實例 (不是公用, 而不XamlObjectReaderXamlXmlReader衍生自或) 上存取 API。However, in one particular case, you access XamlReader API on a practical XAML reader instance that is not public and not derived from XamlObjectReader or XamlXmlReader. 當您呼叫ReadSubtree(它XamlReader會傳回實例) 時, 就會發生這種情況。This case is when you call ReadSubtree, which returns a XamlReader instance. 在預設的執行中, XamlReader此 API 所傳回的是內部類別。In the default implementation, the XamlReader that is returned by this API is an internal class.

XamlReader子樹讀取取得的會對 api Read (例如和NodeType) 具有有效的動作, 而這些動作會以父系讀取器類別為基礎。The XamlReader obtained for subtree reading has valid actions for APIs such as Read and NodeType, and those actions are based on the parent reader class. 這種設計可讓內部類別追蹤已輸入子樹的框架層級。This design enables the internal class to track the frame level where the subtree was entered. [作用中XamlReader ] 子樹可確保當目前的節點位置移到子樹的界限之外時, 特定的子樹讀取器會報告檔null尾或目前節點上的。The acting subtree XamlReader makes sure that if the current node position is moved beyond the bounds of the subtree, the specific subtree reader reports end-of-file or null at the current node.

關於子樹讀取器使用方式的注意事項XamlReader會包含在某些 api 上。Notes about subtree reader usage are included on certain XamlReader APIs.

建構函式

XamlReader()

初始化 XamlReader 類別。Initializes the XamlReader class.

屬性

IsDisposed

取得是否已呼叫 Dispose(Boolean)Gets whether Dispose(Boolean) has been called.

IsEof

在衍生類別中實作時取得值,這個值會報告讀取器位置是否在檔案結尾。When implemented in a derived class, gets a value that reports whether the reader position is at end-of-file.

Member

在衍生類別中實作時,如果讀取器位置在 StartMember 上,則取得讀取器位置上的目前成員。When implemented in a derived class, gets the current member at the reader position, if the reader position is on a StartMember.

Namespace

在衍生類別中實作時,從目前節點取得 XAML 命名空間資訊。When implemented in a derived class, gets the XAML namespace information from the current node.

NodeType

在衍生類別中實作時,會取得目前節點的型別。When implemented in a derived class, gets the type of the current node.

SchemaContext

在衍生類別中實作時取得物件,這個物件會為資訊集提供 XAML 結構描述內容資訊。When implemented in a derived class, gets an object that provides XAML schema context information for the information set.

Type

在衍生類別中實作時,會取得目前節點的 XamlTypeWhen implemented in a derived class, gets the XamlType of the current node.

Value

在衍生類別中實作時,會取得目前節點的值。When implemented in a derived class, gets the value of the current node.

方法

Close()

關閉 XAML 節點資料流。Closes the XAML node stream.

Dispose(Boolean)

釋放 XamlReader 所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。Releases the unmanaged resources used by the XamlReader, and optionally, releases the managed resources.

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
Read()

在衍生類別中實作時,會從來源提供下一個 XAML 節點 (如果有節點的話)。When implemented in a derived class, provides the next XAML node from the source, if a node is available.

ReadSubtree()

傳回以目前 XamlReader 為基礎的 XamlReader,而傳回的 XamlReader 可用來逐一查看 XAML 節點結構的子樹狀結構。Returns a XamlReader that is based on the current XamlReader, where the returned XamlReader is used to iterate through a subtree of the XAML node structure.

Skip()

略過目前節點,並使讀取器位置前進至下一個節點。Skips the current node and advances the reader position to the next node.

ToString()

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

(繼承來源 Object)

明確介面實作

IDisposable.Dispose()

釋放 XamlReader 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the XamlReader class.

適用於

另請參閱