C# Class Tp.Integration.Messages.ServiceBus.Serialization.XmlSerializer

Serializes arbitrary objects to XML.
Inheritance: IDisposable
Datei anzeigen Open project: TargetProcess/Target-Process-Plugins

Private Properties

Property Type Description
CreateGetter object>.Func
GetBinaryConstructorType System.Type
GetGetter object>.Func
GetObjectInfo ObjectInfo
SetObjectInfoAttributes void

Public Methods

Method Description
Dispose ( ) : void

Dispose, release references.

Reset ( ) : void

Clears the Collections.

Serialize ( object obj ) : XmlDocument

Serializes an Object to a new XmlDocument.

Serialize ( object obj, String name, XmlDocument doc ) : void

Serializes an Object and appends it to root (DocumentElement) of the specified XmlDocument.

Serialize ( object obj, String name, XmlNode parent ) : void

Serializes an Object and appends it to the specified XmlNode.

Serialize ( object obj, string filename ) : void

Serializes an Object to a file.

Protected Methods

Method Description
BuildSerializeableTypeDictionary ( ) : Hashtable

Builds the Hashtable that will be written to XML as the type dictionary. TODO: Why Hashtable? Better use a typesafe generic Dictionary. Maybe filesize can be decreased.

While serialization the key of the type dictionary is the Type so it's easy to determine whether a Type is registered already. For deserialization the order is reverse: find a Type for a given key. This methods creates a reversed Hashtable with the Types information stored in TypeInfo instances.

CheckPropertyHasToBeSerialized ( PropertyInfo pi ) : bool

Returns wether the Property has to be serialized or not (depending on SerializationIgnoredAttributeType).

GetTypeKey ( Type type ) : string

Gets the key of a Type from the type dictionary. If the Type is not registered, yet, it will be registered here.

GetTypeKey ( object obj ) : string

Gets the key of a Type from the type dictionary. If the Type is not registered, yet, it will be registered here.

SerializeBinaryObject ( Object obj, Type ctorParamType, XmlNode parent ) : void

Serializes binary data to a XmlNode.

SerializeProperties ( object obj, XmlNode parent ) : void

Serializes the properties an Object and appends them to the specified XmlNode.

SetCollectionItems ( object obj, ICollection value, XmlNode parent ) : void

Sets the items on a collection.

This method could be simplified since it's mainly the same code you can find in SetProperty()

SetProperties ( object obj, XmlElement node ) : void
SetProperty ( object obj, PropertyInfo pi, XmlNode parent ) : void

Sets a property.

SetProperty ( object obj, object value, PropertyInfo pi, XmlNode parent ) : void

Sets a property.

This is the central method which is called recursivly!

SetXmlElementFromBasicPropertyValue ( XmlElement prop, Type pt, object value, XmlNode parent ) : void
WriteTypeDictionary ( XmlNode parentNode ) : void

Writes the TypeDictionary to XML.

Private Methods

Method Description
CreateGetter ( PropertyInfo propertyInfo ) : object>.Func
GetBinaryConstructorType ( Type tpe ) : Type
GetGetter ( PropertyInfo propertyInfo ) : object>.Func
GetObjectInfo ( string name, Type type ) : ObjectInfo

Returns an ObjectInfo filled with the values of Name, Type, and Assembly.

SetObjectInfoAttributes ( String propertyName, Type type, XmlNode node ) : void

Sets the property attributes of a Property to an XmlNode.

Method Details

BuildSerializeableTypeDictionary() protected method

Builds the Hashtable that will be written to XML as the type dictionary. TODO: Why Hashtable? Better use a typesafe generic Dictionary. Maybe filesize can be decreased.
While serialization the key of the type dictionary is the Type so it's easy to determine whether a Type is registered already. For deserialization the order is reverse: find a Type for a given key. This methods creates a reversed Hashtable with the Types information stored in TypeInfo instances.
protected BuildSerializeableTypeDictionary ( ) : Hashtable
return System.Collections.Hashtable

CheckPropertyHasToBeSerialized() protected method

Returns wether the Property has to be serialized or not (depending on SerializationIgnoredAttributeType).
protected CheckPropertyHasToBeSerialized ( PropertyInfo pi ) : bool
pi System.Reflection.PropertyInfo
return bool

Dispose() public method

Dispose, release references.
public Dispose ( ) : void
return void

GetTypeKey() protected method

Gets the key of a Type from the type dictionary. If the Type is not registered, yet, it will be registered here.
protected GetTypeKey ( Type type ) : string
type System.Type
return string

GetTypeKey() protected method

Gets the key of a Type from the type dictionary. If the Type is not registered, yet, it will be registered here.
protected GetTypeKey ( object obj ) : string
obj object
return string

Reset() public method

Clears the Collections.
public Reset ( ) : void
return void

Serialize() public method

Serializes an Object to a new XmlDocument.
public Serialize ( object obj ) : XmlDocument
obj object
return System.Xml.XmlDocument

Serialize() public method

Serializes an Object and appends it to root (DocumentElement) of the specified XmlDocument.
public Serialize ( object obj, String name, XmlDocument doc ) : void
obj object
name String
doc System.Xml.XmlDocument
return void

Serialize() public method

Serializes an Object and appends it to the specified XmlNode.
public Serialize ( object obj, String name, XmlNode parent ) : void
obj object
name String
parent System.Xml.XmlNode
return void

Serialize() public method

Serializes an Object to a file.
public Serialize ( object obj, string filename ) : void
obj object
filename string
return void

SerializeBinaryObject() protected method

Serializes binary data to a XmlNode.
protected SerializeBinaryObject ( Object obj, Type ctorParamType, XmlNode parent ) : void
obj Object
ctorParamType System.Type
parent System.Xml.XmlNode
return void

SerializeProperties() protected method

Serializes the properties an Object and appends them to the specified XmlNode.
protected SerializeProperties ( object obj, XmlNode parent ) : void
obj object
parent System.Xml.XmlNode
return void

SetCollectionItems() protected method

Sets the items on a collection.
This method could be simplified since it's mainly the same code you can find in SetProperty()
protected SetCollectionItems ( object obj, ICollection value, XmlNode parent ) : void
obj object
value ICollection
parent System.Xml.XmlNode
return void

SetProperties() protected method

protected SetProperties ( object obj, XmlElement node ) : void
obj object
node System.Xml.XmlElement
return void

SetProperty() protected method

Sets a property.
protected SetProperty ( object obj, PropertyInfo pi, XmlNode parent ) : void
obj object
pi System.Reflection.PropertyInfo
parent System.Xml.XmlNode
return void

SetProperty() protected method

Sets a property.
This is the central method which is called recursivly!
protected SetProperty ( object obj, object value, PropertyInfo pi, XmlNode parent ) : void
obj object
value object
pi System.Reflection.PropertyInfo
parent System.Xml.XmlNode
return void

SetXmlElementFromBasicPropertyValue() protected method

protected SetXmlElementFromBasicPropertyValue ( XmlElement prop, Type pt, object value, XmlNode parent ) : void
prop System.Xml.XmlElement
pt System.Type
value object
parent System.Xml.XmlNode
return void

WriteTypeDictionary() protected method

Writes the TypeDictionary to XML.
protected WriteTypeDictionary ( XmlNode parentNode ) : void
parentNode System.Xml.XmlNode
return void