Data​Contract​Serializer.​Write​Object Method

Definition

Overloads

Write​Object(​Xml​Writer, ​Object)

Writes all the object data (starting XML element, content, and closing element) to an XML document or stream with an XmlWriter.

Write​Object(​Xml​Dictionary​Writer, ​Object, ​Data​Contract​Resolver)

Writes all the object data (starting XML element, content, and enclosing element) to an XML document or stream using the specified XmlDictionaryWriter. The method includes a resolver for mapping xsi:type declarations at runtime.

WriteObject(XmlWriter, Object)

Writes all the object data (starting XML element, content, and closing element) to an XML document or stream with an XmlWriter.

public override void WriteObject (System.Xml.XmlWriter writer, object graph);
Parameters
writer
XmlWriter

The XmlWriter used to write the XML document or stream.

graph
Object

The object that contains the data to write to the stream.

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 written.

WriteObject(XmlDictionaryWriter, Object, DataContractResolver)

Writes all the object data (starting XML element, content, and enclosing element) to an XML document or stream using the specified XmlDictionaryWriter. The method includes a resolver for mapping xsi:type declarations at runtime.

public void WriteObject (System.Xml.XmlDictionaryWriter writer, object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver);
Parameters
writer
XmlDictionaryWriter

An XmlDictionaryWriter used to write the content to the XML document or stream.

graph
Object

The object that contains the content to write.

dataContractResolver
DataContractResolver

An implementation of the DataContractResolver used to map xsi:type declarations to known data contracts.