XamlXmlWriter Class

.NET Framework (current version)
 

Uses a TextWriter or XmlWriter support class to write a XAML node stream to a text or markup serialized form.

Namespace:   System.Xaml
Assembly:  System.Xaml (in System.Xaml.dll)

System.Object
  System.Xaml.XamlWriter
    System.Xaml.XamlXmlWriter

public class XamlXmlWriter : XamlWriter

NameDescription
System_CAPS_pubmethodXamlXmlWriter(Stream, XamlSchemaContext)

Initializes a new instance of the XamlXmlWriter class from a stream.

System_CAPS_pubmethodXamlXmlWriter(Stream, XamlSchemaContext, XamlXmlWriterSettings)

Initializes a new instance of the XamlXmlWriter class from a stream using a writer settings object.

System_CAPS_pubmethodXamlXmlWriter(TextWriter, XamlSchemaContext)

Initializes a new instance of the XamlXmlWriter class from a TextWriter basis.

System_CAPS_pubmethodXamlXmlWriter(TextWriter, XamlSchemaContext, XamlXmlWriterSettings)

Initializes a new instance of the XamlXmlWriter class from a TextWriter basis using a settings object.

System_CAPS_pubmethodXamlXmlWriter(XmlWriter, XamlSchemaContext)

Initializes a new instance of the XamlXmlWriter class from a XmlWriter basis.

System_CAPS_pubmethodXamlXmlWriter(XmlWriter, XamlSchemaContext, XamlXmlWriterSettings)

Initializes a new instance of the XamlXmlWriter class from a XmlWriter basis using a settings object.

NameDescription
System_CAPS_protpropertyIsDisposed

Gets whether Dispose has been called.(Inherited from XamlWriter.)

System_CAPS_pubpropertySchemaContext

Gets the XAML schema context that this XamlXmlWriter uses for processing.(Overrides XamlWriter.SchemaContext.)

System_CAPS_pubpropertySettings

Gets the writer settings that this XamlXmlWriter uses for XAML processing.

NameDescription
System_CAPS_pubmethodClose()

Closes the XAML writer object.(Inherited from XamlWriter.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by XamlXmlWriter and optionally releases the managed resources. (Overrides XamlWriter.Dispose(Boolean).)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFlush()

Calls the Flush method of the underlying XmlWriter or TextWriter, which writes anything that is currently in the buffer, and then closes the writer.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWriteEndMember()

Writes a XAML end member node to the underlying XmlWriter or TextWriter. Throws an exception if the current position of the XAML node stream is not within a member, or if the internal writer state does not support writing to an end member.(Overrides XamlWriter.WriteEndMember().)

System_CAPS_pubmethodWriteEndObject()

Writes a XAML end object node to the underlying XmlWriter or TextWriter. Throws an exception if the current position of the XAML node stream that is being processed is incompatible with writing an end object.(Overrides XamlWriter.WriteEndObject().)

System_CAPS_pubmethodWriteGetObject()

Writes an object for cases where the specified object is a default or implicit value of the property that is being written, instead of being specified as an object value in the input XAML node set.(Overrides XamlWriter.WriteGetObject().)

System_CAPS_pubmethodWriteNamespace(NamespaceDeclaration)

Writes namespace information to the underlying XmlWriter or TextWriter. May throw an exception for certain states; however, may instead defer writing the namespace information until the writer and the XAML node stream that is being processed reaches a position where a XAML namespace declaration can be inserted.(Overrides XamlWriter.WriteNamespace(NamespaceDeclaration).)

System_CAPS_pubmethodWriteNode(XamlReader)

Performs switching based on node type from the XAML reader (XamlReader.NodeType) and calls the relevant Write method for the writer implementation.(Inherited from XamlWriter.)

System_CAPS_pubmethodWriteStartMember(XamlMember)

Writes a XAML start member node to the underlying XmlWriter or TextWriter. Throws an exception if the current position of the XAML node stream is within another member, or if it is not in a scope or writer state where a start member can be written.(Overrides XamlWriter.WriteStartMember(XamlMember).)

System_CAPS_pubmethodWriteStartObject(XamlType)

Writes a XAML start object node to the underlying XmlWriter or TextWriter. Throws an exception if the current position of the XAML node stream is not in a scope where a start object can be written, or if the writer is not in a state that can write a start object.(Overrides XamlWriter.WriteStartObject(XamlType).)

System_CAPS_pubmethodWriteValue(Object)

Writes a XAML value node to the underlying XmlWriter or TextWriter. Throws an exception if the current position of the XAML node stream is invalid for writing a value, or the writer is in a state where a value cannot be written.(Overrides XamlWriter.WriteValue(Object).)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDisposable.Dispose()

This API supports the product infrastructure and is not intended to be used directly from your code. See Dispose.(Inherited from XamlWriter.)

This class is typically used in serialization scenarios.

The XamlWriter API has several methods that write different types of XAML nodes. Collectively, these are referred to in documentation as the Write methods of a XamlWriter. XamlXmlWriter uses several internal state classes to determine what to do when one of its Write implementations is called. A Write call uses the states to determine whether the requested element, attribute, or value can be written, or whether an exception is thrown. For example, if you call WriteEndObject and the state of the XamlXmlWriter current node position is on a value or within a member, an exception is thrown. Typically, callers of the XamlXmlWriter API should be aware of the type of the current XAML node that is coming from the XAML reader and the XAML node stream. Based on this knowledge, callers should avoid calling Write APIs that are not relevant to the current node type.

The XAML namespace writing behavior of XamlXmlWriter is complex and is not limited to explicit calls to WriteNamespace. Instead, other Write calls, such as WriteStartObject, might require that the namespace declaration be written at particular points in the node structure. The XAML writer either generates a prefix by its own logic, or uses information from the INamespacePrefixLookup service to determine a preferred prefix. Also, explicit WriteNamespace calls might defer or might return nothing if the XAML namespace declaration is already applicable and declared elsewhere.

Exceptions thrown by the XamlXmlWriterWrite methods are typically either InvalidOperationException or XamlXmlWriterException.

An InvalidOperationException often indicates that a XAML reader passed an invalid node structure into the XAML node stream. In this case the node structure is invalid for reasons that are not related to validation of a XAML schema or a XAML schema context. Rather, the node stream is invalid in its basic form. For example, if a faulty XAML reader implementation generated a XAML node stream that contained two consecutive StartObject nodes, the attempt to call the second WriteStartObject would throw an InvalidOperationException. All XAML writers would consider such an operation to be invalid. Another example of an InvalidOperationException is when XAML namespace information is unavailable through the XAML schema context that applies to the current node stream position.

A XamlXmlWriterException indicates an exception where this particular XAML writer implementation chooses to throw an exception based on its intended functionality. A XamlXmlWriterException can indicate specific cases where a XamlXmlWriter violates its own state or settings. For example, a XamlXmlWriterException might result from attempts to write XAML namespace information into a position that the XamlXmlWriter and its serialization format do not support, or writing duplicate members when the instance's XamlXmlWriterSettings forbid it.

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: