C# Class TreeStrategy, simplexml

The TreeStrategy object is used to provide a simple strategy for handling object graphs in a tree structure. This does not resolve cycles in the object graph. This will make use of the specified class attribute to resolve the class to use for a given element during the deserialization process. For the serialization process the "class" attribute will be added to the element specified. If there is a need to use an attribute name other than "class" then the name of the attribute to use can be specified.
Inheritance: Strategy
Show file Open project: ngallagher/simplexml Class Usage Examples

Public Methods

Method Description
Read ( Type type, NodeMap node, Dictionary, map ) : Value,

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. If no such attribute exists on the element this returns null.

ReadArray ( Class, type, NodeMap node ) : Value,

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. This also expects a "length" attribute for the array length.

ReadValue ( Type type, NodeMap node ) : Class,

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. If no such attribute exists the specified field is returned, or if the field type is an array then the component type.

TreeStrategy ( ) : SimpleFramework.Xml.Stream

Constructor for the TreeStrategy object. This is used to create a strategy that can resolve and load class objects for deserialization using a "class" attribute. Also for serialization this will add the appropriate "class" value.

TreeStrategy ( String label, String length ) : SimpleFramework.Xml.Stream

Constructor for the TreeStrategy object. This is used to create a strategy that can resolve and load class objects for deserialization using the specified attribute. The attribute value can be any legal XML attribute name.

Write ( Type type, Object value, NodeMap node, Dictionary, map ) : bool

This is used to attach a attribute to the provided element that is used to identify the class. The attribute name is "class" and has the value of the fully qualified class name for the object provided. This will only be invoked if the object class is different from the field class.

WriteArray ( Class, field, Object value, NodeMap node ) : Class,

This is used to add a length attribute to the element due to the fact that the serialized value is an array. The length of the array is acquired and inserted in to the attributes.

Method Details

Read() public method

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. If no such attribute exists on the element this returns null.
public Read ( Type type, NodeMap node, Dictionary, map ) : Value,
type Type /// this is the type of the XML element expected ///
node NodeMap /// this is the element used to resolve an override ///
map Dictionary, /// this is used to maintain contextual information ///
return Value,

ReadArray() public method

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. This also expects a "length" attribute for the array length.
public ReadArray ( Class, type, NodeMap node ) : Value,
type Class, /// this is the type of the XML element expected ///
node NodeMap /// this is the element used to resolve an override ///
return Value,

ReadValue() public method

This is used to resolve and load a class for the given element. Resolution of the class to used is done by inspecting the XML element provided. If there is a "class" attribute on the element then its value is used to resolve the class to use. If no such attribute exists the specified field is returned, or if the field type is an array then the component type.
public ReadValue ( Type type, NodeMap node ) : Class,
type Type /// this is the type of the XML element expected ///
node NodeMap /// this is the element used to resolve an override ///
return Class,

TreeStrategy() public method

Constructor for the TreeStrategy object. This is used to create a strategy that can resolve and load class objects for deserialization using a "class" attribute. Also for serialization this will add the appropriate "class" value.
public TreeStrategy ( ) : SimpleFramework.Xml.Stream
return SimpleFramework.Xml.Stream

TreeStrategy() public method

Constructor for the TreeStrategy object. This is used to create a strategy that can resolve and load class objects for deserialization using the specified attribute. The attribute value can be any legal XML attribute name.
public TreeStrategy ( String label, String length ) : SimpleFramework.Xml.Stream
label String /// this is the name of the attribute to use ///
length String /// this is used to determine the array length ///
return SimpleFramework.Xml.Stream

Write() public method

This is used to attach a attribute to the provided element that is used to identify the class. The attribute name is "class" and has the value of the fully qualified class name for the object provided. This will only be invoked if the object class is different from the field class.
public Write ( Type type, Object value, NodeMap node, Dictionary, map ) : bool
type Type /// this is the declared class for the field used ///
value Object /// this is the instance variable being serialized ///
node NodeMap /// this is the element used to represent the value ///
map Dictionary, /// this is used to maintain contextual information ///
return bool

WriteArray() public method

This is used to add a length attribute to the element due to the fact that the serialized value is an array. The length of the array is acquired and inserted in to the attributes.
public WriteArray ( Class, field, Object value, NodeMap node ) : Class,
field Class, /// this is the field type for the array to set ///
value Object /// this is the actual value for the array to set ///
node NodeMap /// this is the map of attributes for the element ///
return Class,