C# Class SimpleFramework.Xml.Core.Factory

The Factory object provides a base class for factories used to produce field values from XML elements. The goal of this type of factory is to make use of the Strategy object to determine the type of the field value. The strategy class must be assignable to the field class type, that is, it must extend it or implement it if it represents an interface. If the strategy returns a null Value then the subclass implementation determines the type used to populate the object field value.
ファイルを表示 Open project: ngallagher/simplexml

Protected Properties

Property Type Description
context Context
support Support
type System.Type

Public Methods

Method Description
GetConversion ( InputNode node ) : Value

This performs the conversion from the element node to a type. This is where the Strategy object is consulted and asked for a class that will represent the provided XML element. This will, depending on the strategy implementation, make use of attributes and/or elements to determine the type for the field.

GetOverride ( InputNode node ) : Value
IsCompatible ( Class expect, Class type ) : bool

This is used to determine whether the provided base class can be assigned from the issued type. For an override to be compatible with the field type an instance of the override type must be assignable to the field value.

IsInstantiable ( Class type ) : bool

This is used to determine whether the type given is instantiable, that is, this determines if an instance of that type can be created. If the type is an interface or an abstract class then this will return false.

SetOverride ( Type type, Object value, OutputNode node ) : bool

This method is used to set the override class within an element. This delegates to the Strategy implementation, which depending on the implementation may add an attribute of a child element to describe the type of the object provided to this.

Protected Methods

Method Description
Factory ( Context context, Type type ) : SimpleFramework.Xml.Strategy

Constructor for the Factory object. This is given the class type for the field that this factory will determine the actual type for. The actual type must be assignable to the field type to insure that any instance can be set.

Method Details

Factory() protected method

Constructor for the Factory object. This is given the class type for the field that this factory will determine the actual type for. The actual type must be assignable to the field type to insure that any instance can be set.
protected Factory ( Context context, Type type ) : SimpleFramework.Xml.Strategy
context Context /// the contextual object used by the persister ///
type System.Type /// this is the property representing the field ///
return SimpleFramework.Xml.Strategy

GetConversion() public method

This performs the conversion from the element node to a type. This is where the Strategy object is consulted and asked for a class that will represent the provided XML element. This will, depending on the strategy implementation, make use of attributes and/or elements to determine the type for the field.
public GetConversion ( InputNode node ) : Value
node InputNode /// this is the element used to extract the override ///
return Value

GetOverride() public method

public GetOverride ( InputNode node ) : Value
node InputNode /// this is the node used to search for the override ///
return Value

IsCompatible() public method

This is used to determine whether the provided base class can be assigned from the issued type. For an override to be compatible with the field type an instance of the override type must be assignable to the field value.
public IsCompatible ( Class expect, Class type ) : bool
expect Class /// this is the field value present the the object ///
type Class /// this is the specialized type that will be assigned ///
return bool

IsInstantiable() public method

This is used to determine whether the type given is instantiable, that is, this determines if an instance of that type can be created. If the type is an interface or an abstract class then this will return false.
public IsInstantiable ( Class type ) : bool
type Class /// this is the type to check the modifiers of ///
return bool

SetOverride() public method

This method is used to set the override class within an element. This delegates to the Strategy implementation, which depending on the implementation may add an attribute of a child element to describe the type of the object provided to this.
public SetOverride ( Type type, Object value, OutputNode node ) : bool
type System.Type /// this is the class of the field type being serialized ///
value Object
node OutputNode /// the XML element that is to be given the details ///
return bool

Property Details

context protected_oe property

This is the context object used for the serialization process.
protected Context context
return Context

support protected_oe property

This is used to translate all of the primitive type strings.
protected Support,SimpleFramework.Xml.Core support
return Support

type protected_oe property

This is the field type that the class must be assignable to.
protected Type,System type
return System.Type