C# Class SimpleFramework.Xml.Util.AnnotationStrategy

The AnnotationStrategy object is used to intercept the serialization process and delegate to custom converters. This strategy uses the Convert annotation to specify the converter to use for serialization and deserialization. If there is no annotation present on the field or method representing the object instance to be serialized then this acts as a transparent proxy to an internal strategy.

By default the TreeStrategy is used to perform the normal serialization process should there be no annotation specifying a converter to use. However, any implementation can be used, including the CycleStrategy, which handles cycles in the object graph. To specify the internal strategy to use it can be provided in the constructor.

Inheritance: Strategy
Show file Open project: ngallagher/simplexml Class Usage Examples

Public Methods

Method Description
AnnotationStrategy ( ) : SimpleFramework.Xml.Strategy

Constructor for the AnnotationStrategy object. This creates a strategy that intercepts serialization on any annotated method or field. If no annotation exists then this delegates to an internal TreeStrategy object.

AnnotationStrategy ( Strategy strategy ) : SimpleFramework.Xml.Strategy

Constructor for the AnnotationStrategy object. This creates a strategy that intercepts serialization on any annotated method or field. If no annotation exists then this will delegate to the Strategy provided.

IsReference ( Value value ) : bool

This is used to determine if the Value provided represents a reference. If it does represent a reference then this will return true, if it does not then this returns false.

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

This is used to read the Value which will be used to represent the deserialized object. If there is an annotation present then the value will contain an object instance. If it does not then it is up to the internal strategy to determine what the returned value contains.

Read ( Type type, NodeMap node, Value value ) : Value

This is used to read the Value which will be used to represent the deserialized object. If there is an annotation present then the value will contain an object instance. If it does not then it is up to the internal strategy to determine what the returned value contains.

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

This is used to serialize a representation of the object value provided. If there is a Convert annotation present on the provided type then this will use the converter specified to serialize a representation of the object. If however there is no annotation then this will delegate to the internal strategy. This returns true if the serialization has completed.

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

This is used to serialize a representation of the object value provided. If there is a Convert annotation present on the provided type then this will use the converter specified to serialize a representation of the object. If however there is no annotation then this will delegate to the internal strategy. This returns true if the serialization has completed.

Method Details

AnnotationStrategy() public method

Constructor for the AnnotationStrategy object. This creates a strategy that intercepts serialization on any annotated method or field. If no annotation exists then this delegates to an internal TreeStrategy object.
public AnnotationStrategy ( ) : SimpleFramework.Xml.Strategy
return SimpleFramework.Xml.Strategy

AnnotationStrategy() public method

Constructor for the AnnotationStrategy object. This creates a strategy that intercepts serialization on any annotated method or field. If no annotation exists then this will delegate to the Strategy provided.
public AnnotationStrategy ( Strategy strategy ) : SimpleFramework.Xml.Strategy
strategy Strategy /// the internal strategy to delegate to ///
return SimpleFramework.Xml.Strategy

IsReference() public method

This is used to determine if the Value provided represents a reference. If it does represent a reference then this will return true, if it does not then this returns false.
public IsReference ( Value value ) : bool
value Value /// this is the value instance to be evaluated ///
return bool

Read() public method

This is used to read the Value which will be used to represent the deserialized object. If there is an annotation present then the value will contain an object instance. If it does not then it is up to the internal strategy to determine what the returned value contains.
public Read ( Type type, NodeMap node, Dictionary map ) : Value
type System.Type /// this is the type that represents a method or field ///
node NodeMap /// this is the node representing the XML element ///
map Dictionary /// this is the session map that contain variables ///
return Value

Read() public method

This is used to read the Value which will be used to represent the deserialized object. If there is an annotation present then the value will contain an object instance. If it does not then it is up to the internal strategy to determine what the returned value contains.
public Read ( Type type, NodeMap node, Value value ) : Value
type System.Type /// this is the type that represents a method or field ///
node NodeMap /// this is the node representing the XML element ///
value Value /// this is the value from the internal strategy ///
return Value

Write() public method

This is used to serialize a representation of the object value provided. If there is a Convert annotation present on the provided type then this will use the converter specified to serialize a representation of the object. If however there is no annotation then this will delegate to the internal strategy. This returns true if the serialization has completed.
public Write ( Type type, Object value, NodeMap node ) : bool
type System.Type /// this is the type that represents the field or method ///
value Object /// this is the object instance to be serialized ///
node NodeMap /// this is the XML element to be serialized to ///
return bool

Write() public method

This is used to serialize a representation of the object value provided. If there is a Convert annotation present on the provided type then this will use the converter specified to serialize a representation of the object. If however there is no annotation then this will delegate to the internal strategy. This returns true if the serialization has completed.
public Write ( Type type, Object value, NodeMap node, Dictionary map ) : bool
type System.Type /// this is the type that represents the field or method ///
value Object /// this is the object instance to be serialized ///
node NodeMap /// this is the XML element to be serialized to ///
map Dictionary /// this is the session map used by the serializer ///
return bool