DomainClassXmlSerializer.TryCreateInstance Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
With the given XmlReader, check if it is currently pointing to a serialized ModelElement instance that this serializer can handle. If so, create an instance of the ModelElement in the given Partition; otherwise return NULL. Note: The caller will guarantee that the reader is positioned at open XML tag of the element being read. This method should not move the reader; the reader should remain at the same position when this method returns.
public:
virtual Microsoft::VisualStudio::Modeling::ModelElement ^ TryCreateInstance(Microsoft::VisualStudio::Modeling::SerializationContext ^ serializationContext, System::Xml::XmlReader ^ reader, Microsoft::VisualStudio::Modeling::Partition ^ partition);
public virtual Microsoft.VisualStudio.Modeling.ModelElement TryCreateInstance (Microsoft.VisualStudio.Modeling.SerializationContext serializationContext, System.Xml.XmlReader reader, Microsoft.VisualStudio.Modeling.Partition partition);
abstract member TryCreateInstance : Microsoft.VisualStudio.Modeling.SerializationContext * System.Xml.XmlReader * Microsoft.VisualStudio.Modeling.Partition -> Microsoft.VisualStudio.Modeling.ModelElement
override this.TryCreateInstance : Microsoft.VisualStudio.Modeling.SerializationContext * System.Xml.XmlReader * Microsoft.VisualStudio.Modeling.Partition -> Microsoft.VisualStudio.Modeling.ModelElement
Public Overridable Function TryCreateInstance (serializationContext As SerializationContext, reader As XmlReader, partition As Partition) As ModelElement
Parameters
- serializationContext
- SerializationContext
Serialization context.
- reader
- XmlReader
XmlReader to read from.
- partition
- Partition
Partition in which the new element will be created.
Returns
The created ModelElement instance, or null if the reader is not pointing to a correct serialized instance.
Remarks
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.