Freigeben über


SerializationContext Class

Definition

This class defines the context of a serialization operation. The context passed to each participating serializers to provide information that they may use, and the context stores serialization results collected from each participating serializers.

public ref class SerializationContext sealed
public sealed class SerializationContext
type SerializationContext = class
Public NotInheritable Class SerializationContext
Inheritance
SerializationContext

Constructors

SerializationContext(DomainXmlSerializerDirectory, String, SerializationResult)

Create a serialization context with given source/destination location and SeralizationResult.

SerializationContext(DomainXmlSerializerDirectory, String)

Create a serialization context with given source/destination location.

SerializationContext(DomainXmlSerializerDirectory)

Create a serialization context with no source/destination location information.

Fields

TransactionContextKey

Unique key used to identify SerializationContext instances in the TransactionContext property bag

Properties

Directory

A serializer instance needs to look up for other serializer instances during serialization/deserialization, so this directory provides the lookup service.

Item[String]

Indexer to access properties stored in this context. The property name is compared by case-sensitive ordinal string comparison. If a property already exists in the context, setting it will override the old value with the new value. If a property doesn't exist in the context, getting it will return null, therefore setting a property to null will remove it from the context (i.e. null and non-existing values are not distinguishable).

Location

In read operation, this is the source's location; in write operation, this is the destination location. Usually this is a file path, but it can be other format as well, depending on the underlying source/destination. It can be null as well if the location is not available, e.g. serializing to a string buffer.

Result

This is the SerializationResult collected from all serializers participating in the current serialization operation.

WriteOptionalPropertiesWithDefaultValue

Whether optional properties with default value should be written out during serialization.

Applies to