XmlSerializerSerializeContent(XmlWriter, Object, XmlSerializationOptions) Method

Saves public properties or collection elements of an object given in obj parameter by an already opened XmlWriter object given in writer parameter with provided options.

Definition

Namespace: KGySoft.Serialization.Xml
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public static void SerializeContent(
	XmlWriter writer,
	Object obj,
	XmlSerializationOptions options = XmlSerializationOptions.CompactSerializationOfPrimitiveArrays|XmlSerializationOptions.EscapeNewlineCharacters
)

Parameters

writer  XmlWriter
A preconfigured XmlWriter object that will be used for serialization. The writer must be in proper state to serialize obj properly and will not be closed or flushed after serialization.
obj  Object
The object, which inner content should be serialized. Parameter value must not be .
options  XmlSerializationOptions  (Optional)
Options for serialization. This parameter is optional.
Default value: CompactSerializationOfPrimitiveArrays, EscapeNewlineCharacters

Remarks

If the provided object in obj parameter is a collection, then elements will be serialized, too. If you want to serialize a primitive type, then use the Serialize(XmlWriter, Object, XmlSerializationOptions) method.

Exceptions

ArgumentNullExceptionobj and writer must not be .
NotSupportedExceptionSerialization is not supported with provided options
ReflectionExceptionThe object hierarchy to serialize contains circular reference.

See Also