Edit

Share via


XmlObjectSerializer.WriteObjectContent Method

Definition

Writes only the content of an object to an XML document or stream.

Overloads

WriteObjectContent(XmlDictionaryWriter, Object)

Writes only the content of the object to the XML document or stream using the specified XmlDictionaryWriter.

WriteObjectContent(XmlWriter, Object)

Writes only the content of the object to the XML document or stream with the specified XmlWriter.

Remarks

The WriteStartObject, WriteObjectContent, and WriteEndObject methods must be implemented. The three methods are used in succession to write the complete serialization using the pattern: write start, write content, and write end. If the implementation writes using XML elements, attributes can be inserted before writing the contents of the object. The three methods are also called by the virtual implementation of the WriteObject method.

WriteObjectContent(XmlDictionaryWriter, Object)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Writes only the content of the object to the XML document or stream using the specified XmlDictionaryWriter.

public:
 abstract void WriteObjectContent(System::Xml::XmlDictionaryWriter ^ writer, System::Object ^ graph);
public abstract void WriteObjectContent (System.Xml.XmlDictionaryWriter writer, object graph);
public abstract void WriteObjectContent (System.Xml.XmlDictionaryWriter writer, object? graph);
abstract member WriteObjectContent : System.Xml.XmlDictionaryWriter * obj -> unit
Public MustOverride Sub WriteObjectContent (writer As XmlDictionaryWriter, graph As Object)

Parameters

writer
XmlDictionaryWriter

An XmlDictionaryWriter used to write the XML document or stream.

graph
Object

The object that contains the content to write.

Exceptions

the type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

there is a problem with the instance being serialized.

the maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

Applies to

WriteObjectContent(XmlWriter, Object)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Writes only the content of the object to the XML document or stream with the specified XmlWriter.

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

Parameters

writer
XmlWriter

An XmlWriter used to write the XML document or stream.

graph
Object

The object that contains the content to write.

Exceptions

the type being serialized does not conform to data contract rules. For example, the DataContractAttribute attribute has not been applied to the type.

there is a problem with the instance being serialized.

the maximum number of objects to serialize has been exceeded. Check the MaxItemsInObjectGraph property.

Applies to