C# Класс SimpleFramework.Xml.Core.Traverser

The Traverser object is used to traverse the XML class schema and either serialize or deserialize an object. This is the root of all serialization and deserialization operations. It uses the Root annotation to ensure that the XML schema matches the provided XML element. If no root element is defined the serialization and deserialization cannot be performed.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetComposite ( Class expect ) : Composite

This will create a Composite object using the XML schema class provided. This makes use of the source object that this traverser has been given to create a composite converter.

GetDecorator ( Class type ) : Decorator

This will acquire the Decorator for the type. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.

GetName ( Class type ) : String

Extracts the Root annotation from the provided XML schema class. If no annotation exists in the provided class the super class is checked and so on until the Object is encountered, if no annotation is found this returns null.

GetType ( Class type ) : Type

This is used to acquire a type for the provided class. This will wrap the class in a Type wrapper object. Wrapping the class allows it to be used within the framework.

Read ( InputNode node, Class type ) : Object

This read method is used to deserialize an object from the provided XML element. The class provided acts as the XML schema definition used to control the deserialization. If the XML schema does not have a Root annotation this throws an exception. Also if the root annotation name is not the same as the XML element name an exception is thrown.

Read ( InputNode node, Class type, Object value ) : Object

This read method is used to deserialize an object from the provided XML element. The class provided acts as the XML schema definition used to control the deserialization. If the XML schema does not have a Root annotation this throws an exception. Also if the root annotation name is not the same as the XML element name an exception is thrown.

Read ( InputNode node, Object value ) : Object

This read method will read the contents of the XML document from the provided source and populate the object with the values deserialized. This is used as a means of injecting an object with values deserialized from an XML document. If the XML source cannot be deserialized or there is a problem building the object graph an exception is thrown.

Traverser ( Context context ) : SimpleFramework.Xml.Strategy

Constructor for the Traverser object. This creates a traverser that can be used to perform serialization or or deserialization of an object. This requires a source object.

Validate ( InputNode node, Class type ) : bool

This validate method will validate the contents of the XML document against the specified XML class schema. This is used to perform a read traversal of the class schema such that the document can be tested against it. This is preferred to reading the document as it does not instantiate the objects or invoke any callback methods, thus making it a safe validation.

Write ( OutputNode node, Object source ) : void

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.

Write ( OutputNode node, Object source, Class expect ) : void

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.

Write ( OutputNode node, Object source, Class expect, String name ) : void

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.

Описание методов

GetComposite() публичный Метод

This will create a Composite object using the XML schema class provided. This makes use of the source object that this traverser has been given to create a composite converter.
public GetComposite ( Class expect ) : Composite
expect Class /// this is the XML schema class to be used ///
Результат Composite

GetDecorator() публичный Метод

This will acquire the Decorator for the type. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.
public GetDecorator ( Class type ) : Decorator
type Class /// this is the type to acquire the decorator for ///
Результат Decorator

GetName() публичный Метод

Extracts the Root annotation from the provided XML schema class. If no annotation exists in the provided class the super class is checked and so on until the Object is encountered, if no annotation is found this returns null.
public GetName ( Class type ) : String
type Class /// this is the XML schema class to use ///
Результат String

GetType() публичный Метод

This is used to acquire a type for the provided class. This will wrap the class in a Type wrapper object. Wrapping the class allows it to be used within the framework.
public GetType ( Class type ) : Type
type Class /// this is the type that is to be wrapped for use ///
Результат System.Type

Read() публичный Метод

This read method is used to deserialize an object from the provided XML element. The class provided acts as the XML schema definition used to control the deserialization. If the XML schema does not have a Root annotation this throws an exception. Also if the root annotation name is not the same as the XML element name an exception is thrown.
public Read ( InputNode node, Class type ) : Object
node InputNode /// this is the node that is to be deserialized ///
type Class /// this is the XML schema class to be used ///
Результат Object

Read() публичный Метод

This read method is used to deserialize an object from the provided XML element. The class provided acts as the XML schema definition used to control the deserialization. If the XML schema does not have a Root annotation this throws an exception. Also if the root annotation name is not the same as the XML element name an exception is thrown.
public Read ( InputNode node, Class type, Object value ) : Object
node InputNode /// this is the node that is to be deserialized ///
type Class
value Object /// this is the XML schema object to be used ///
Результат Object

Read() публичный Метод

This read method will read the contents of the XML document from the provided source and populate the object with the values deserialized. This is used as a means of injecting an object with values deserialized from an XML document. If the XML source cannot be deserialized or there is a problem building the object graph an exception is thrown.
public Read ( InputNode node, Object value ) : Object
node InputNode /// this is the node that is to be deserialized ///
value Object /// this is the value that is to be deserialized ///
Результат Object

Traverser() публичный Метод

Constructor for the Traverser object. This creates a traverser that can be used to perform serialization or or deserialization of an object. This requires a source object.
public Traverser ( Context context ) : SimpleFramework.Xml.Strategy
context Context /// the context object used for the traversal ///
Результат SimpleFramework.Xml.Strategy

Validate() публичный Метод

This validate method will validate the contents of the XML document against the specified XML class schema. This is used to perform a read traversal of the class schema such that the document can be tested against it. This is preferred to reading the document as it does not instantiate the objects or invoke any callback methods, thus making it a safe validation.
public Validate ( InputNode node, Class type ) : bool
node InputNode /// this provides the source of the XML document ///
type Class /// this is the class type to be validated against XML ///
Результат bool

Write() публичный Метод

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.
public Write ( OutputNode node, Object source ) : void
node OutputNode
source Object /// this is the object to be serialized to XML ///
Результат void

Write() публичный Метод

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.
public Write ( OutputNode node, Object source, Class expect ) : void
node OutputNode
source Object /// this is the object to be serialized to XML ///
expect Class /// this is the class that is expected to be written ///
Результат void

Write() публичный Метод

This write method is used to convert the provided object to an XML element. This creates a child node from the given OutputNode object. Once this child element is created it is populated with the fields of the source object in accordance with the XML schema class.
public Write ( OutputNode node, Object source, Class expect, String name ) : void
node OutputNode
source Object /// this is the object to be serialized to XML ///
expect Class /// this is the class that is expected to be written ///
name String /// this is the name of the root annotation used ///
Результат void