DomainClassXmlSerializer::TryCreateInstance Method (SerializationContext^, XmlReader^, Partition^)

 

Checks if the given XmlReader is pointing to a serialized model element instance that this serializer can handle.

Namespace:   Microsoft.VisualStudio.Modeling
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

public:
virtual ModelElement^ TryCreateInstance(
	SerializationContext^ serializationContext,
	XmlReader^ reader,
	Partition^ partition
)

Parameters

serializationContext
Type: Microsoft.VisualStudio.Modeling::SerializationContext^

The serialization context that stores serialization errors, if any.

reader
Type: System.Xml::XmlReader^

The XmlReader from which to read.

partition
Type: Microsoft.VisualStudio.Modeling::Partition^

The partition in which the new element will be created.

Return Value

Type: Microsoft.VisualStudio.Modeling::ModelElement^

The created model element instance, or null if the reader is not pointing to a correct serialized instance.

Note: that this method only tries to create the ModelElement instance, without actually deserializing it. The deserialization will be done by the Read() methods. There are two reasons for this separation: 1) We may need to link the created ModelElement to its parent element (through embedding relationship) before we can deserializing it properly. 2) The deserialization can be customized.

Return to top
Show: