Edit

Share via


XamlObjectWriter.WriteGetObject Method

Definition

Writes the conceptual StartObject into the object graph when the specified object is a default or implicit value of the parent property. The implicit value comes from information that is obtained from the XAML schema context and backing type information, instead of being specified as an object value in the input XAML node set.

public:
 override void WriteGetObject();
public override void WriteGetObject ();
override this.WriteGetObject : unit -> unit
Public Overrides Sub WriteGetObject ()

Remarks

The difference between writing with WriteGetObject and writing with WriteStartObject can be seen in the resulting object graph. WriteGetObject does not construct an instance of a type because the WriteGetObject API has no information to inform the object graph of what to construct. Instead, the object was created when the parent property was initialized; so a XamlObjectWriter does not need to construct it. In contrast, WriteStartObject specifies that an instance of that type should be constructed and inserted into the object graph.

If you think of the XAML node stream as a series of frames, a WriteGetObject is balanced to a WriteEndObject call. Therefore, the number of WriteGetObject plus WriteStartObject calls should equal the number of WriteEndObject calls as part of a complete object-writing evaluation of the XAML node stream.

The conceptual StartObject position for an implicit object in the object graph is necessary because although the object value itself is an implicit default, that object might still have members that need to be written based on the XAML node stream. A typical scenario where this occurs is when XamlObjectWriter writes member nodes for a collection property, and the collection initialization is implicit to creating the object that owns the collection property.

Applies to