XmlObjectSerializer.WriteObject 方法

定義

將所有的物件資料 (起始 XML 項目、內容以及結尾項目) 寫入至 XML 文件或資料流。

多載

WriteObject(Stream, Object)

使用指定的 Stream,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

WriteObject(XmlDictionaryWriter, Object)

使用指定的 XmlDictionaryWriter,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

WriteObject(XmlWriter, Object)

使用指定的 XmlWriter,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

WriteObject(Stream, Object)

來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs

使用指定的 Stream,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

public:
 virtual void WriteObject(System::IO::Stream ^ stream, System::Object ^ graph);
public virtual void WriteObject (System.IO.Stream stream, object graph);
public virtual void WriteObject (System.IO.Stream stream, object? graph);
abstract member WriteObject : System.IO.Stream * obj -> unit
override this.WriteObject : System.IO.Stream * obj -> unit
Public Overridable Sub WriteObject (stream As Stream, graph As Object)

參數

stream
Stream

Stream,用於寫入 XML 文件或資料流。

graph
Object

包含要寫入至資料流之資料的物件。

例外狀況

正在序列化的型別不符合資料合約規則。 例如,DataContractAttribute 屬性尚未套用至此型別。

正在序列化的執行個體發生問題。

已超過要序列化的物件數目上限。 檢查 MaxItemsInObjectGraph 屬性。

適用於

WriteObject(XmlDictionaryWriter, Object)

來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs

使用指定的 XmlDictionaryWriter,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

public:
 virtual void WriteObject(System::Xml::XmlDictionaryWriter ^ writer, System::Object ^ graph);
public virtual void WriteObject (System.Xml.XmlDictionaryWriter writer, object graph);
public virtual void WriteObject (System.Xml.XmlDictionaryWriter writer, object? graph);
abstract member WriteObject : System.Xml.XmlDictionaryWriter * obj -> unit
override this.WriteObject : System.Xml.XmlDictionaryWriter * obj -> unit
Public Overridable Sub WriteObject (writer As XmlDictionaryWriter, graph As Object)

參數

writer
XmlDictionaryWriter

XmlDictionaryWriter,用來將內容寫入至 XML 文件或資料流。

graph
Object

包含要寫入之內容的物件。

例外狀況

正在序列化的型別不符合資料合約規則。 例如,DataContractAttribute 屬性尚未套用至此型別。

正在序列化的執行個體發生問題。

已超過要序列化的物件數目上限。 檢查 MaxItemsInObjectGraph 屬性。

備註

這是一種虛擬方法,其預設實作會呼叫 WriteStartObject, WriteObjectContentWriteEndObject 方法。 拜這項特性之賜,這個方法是最常用在序列化程式上的方法。

適用於

WriteObject(XmlWriter, Object)

來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs
來源:
XmlObjectSerializer.cs

使用指定的 XmlWriter,將物件的完整內容 (開始、內容和結束) 寫入至 XML 文件或資料流。

public:
 virtual void WriteObject(System::Xml::XmlWriter ^ writer, System::Object ^ graph);
public virtual void WriteObject (System.Xml.XmlWriter writer, object graph);
public virtual void WriteObject (System.Xml.XmlWriter writer, object? graph);
abstract member WriteObject : System.Xml.XmlWriter * obj -> unit
override this.WriteObject : System.Xml.XmlWriter * obj -> unit
Public Overridable Sub WriteObject (writer As XmlWriter, graph As Object)

參數

writer
XmlWriter

用來撰寫 XML 文件或資料流的 XmlWriter

graph
Object

包含要寫入之內容的物件。

例外狀況

正在序列化的型別不符合資料合約規則。 例如,DataContractAttribute 屬性尚未套用至此型別。

正在序列化的執行個體發生問題。

已超過要序列化的物件數目上限。 檢查 MaxItemsInObjectGraph 屬性。

備註

這是一種虛擬方法,其預設實作會委派寫入至 XmlObjectSerializer.WriteObject(XmlDictionaryWriter, Object) 多載。

適用於