C# Class SimpleFramework.Xml.Strategy.VisitorStrategy

The VisitorStrategy object is a simplification of a strategy, which allows manipulation of the serialization process. Typically implementing a Strategy is impractical as it requires the implementation to determine the type a node represents. Instead it is often easier to visit each node that is being serialized or deserialized and manipulate it so that the resulting XML can be customized.

To perform customization in this way a Visitor can be implemented. This can be passed to this strategy which will ensure the visitor is given each XML element as it is either being serialized or deserialized. Such an inversion of control allows the nodes to be manipulated with little effort. By default this used TreeStrategy object as a default strategy to delegate to. However, any strategy can be used.

Inheritance: Strategy
ファイルを表示 Open project: ngallagher/simplexml Class Usage Examples

Public Methods

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

This method will read with an internal strategy after it has been intercepted by the visitor. Interception of the XML node before it is delegated to the internal strategy allows the visitor to change some attributes or details before the node is interpreted by the strategy.

VisitorStrategy ( Visitor visitor ) : SimpleFramework.Xml.Stream

Constructor for the VisitorStrategy object. This strategy requires a visitor implementation that can be used to intercept the serialization and deserialization process.

VisitorStrategy ( Visitor visitor, Strategy strategy ) : SimpleFramework.Xml.Stream

Constructor for the VisitorStrategy object. This strategy requires a visitor implementation that can be used to intercept the serialization and deserialization process.

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

This method will write with an internal strategy before it has been intercepted by the visitor. Interception of the XML node before it is delegated to the internal strategy allows the visitor to change some attributes or details before the node is interpreted by the strategy.

Method Details

Read() public method

This method will read with an internal strategy after it has been intercepted by the visitor. Interception of the XML node before it is delegated to the internal strategy allows the visitor to change some attributes or details before the node is interpreted by the strategy.
public Read ( Type type, NodeMap node, Dictionary map ) : Value
type System.Type /// this is the type of the root element expected ///
node NodeMap /// this is the node map used to resolve an override ///
map Dictionary /// this is used to maintain contextual information ///
return Value

VisitorStrategy() public method

Constructor for the VisitorStrategy object. This strategy requires a visitor implementation that can be used to intercept the serialization and deserialization process.
public VisitorStrategy ( Visitor visitor ) : SimpleFramework.Xml.Stream
visitor Visitor /// this is the visitor used for interception ///
return SimpleFramework.Xml.Stream

VisitorStrategy() public method

Constructor for the VisitorStrategy object. This strategy requires a visitor implementation that can be used to intercept the serialization and deserialization process.
public VisitorStrategy ( Visitor visitor, Strategy strategy ) : SimpleFramework.Xml.Stream
visitor Visitor /// this is the visitor used for interception ///
strategy Strategy /// this is the strategy to be delegated to ///
return SimpleFramework.Xml.Stream

Write() public method

This method will write with an internal strategy before it has been intercepted by the visitor. Interception of the XML node before it is delegated to the internal strategy allows the visitor to change some attributes or details before the node is interpreted by the strategy.
public Write ( Type type, Object value, NodeMap node, Dictionary map ) : bool
type System.Type /// this is the type of the root element expected ///
value Object
node NodeMap /// this is the node map used to resolve an override ///
map Dictionary /// this is used to maintain contextual information ///
return bool