C# Class Xml.Net.Utilities

A selection of common methods called from multiple classes.
Mostra file Open project: hughbe/xml.net

Public Methods

Method Description
AddChildElement ( System.Xml.Linq.XElement child, System.Xml.Linq.XElement parent ) : void

Adds the specified XElement to the parent XElement if it is not null;

GetChildElement ( string name, System.Xml.Linq.XElement parent ) : System.Xml.Linq.XElement

Gets the name-specified child XElement of the parent XElement.

GetCollectionElementName ( PropertyInfo property ) : string

Gets the custom name of collection elements of a property. Defaults to "Element".

GetDictionaryElementName ( PropertyInfo property ) : string>.KeyValuePair

Gets the custom name of collection key and value elements of a property.

GetElementType ( System.Xml.Linq.XElement element, Type parentType, int genericArgumentIndex ) : Type

Gets the type of an object from its serialized XElement (e.g. if it has a type attribute) and its parent container type (e.g. if it is generic).

GetIdentifier ( MemberInfo memberInfo ) : string

Gets the XML identifier of the member.

GetIdentifier ( object obj ) : string

Gets the XML identifier of the class from an object of that class.

SetupSerializedElement ( object value, System.Xml.Linq.XElement element, XmlConvertOptions options ) : System.Xml.Linq.XElement

Formats a serialized XElement with options.

ShouldIgnoreProperty ( PropertyInfo property ) : bool

Checks if a property should not be serialized.

Method Details

AddChildElement() public static method

Adds the specified XElement to the parent XElement if it is not null;
public static AddChildElement ( System.Xml.Linq.XElement child, System.Xml.Linq.XElement parent ) : void
child System.Xml.Linq.XElement The child XElement to add to the parent XElement.
parent System.Xml.Linq.XElement The parent XElement to add the child XElement to.
return void

GetChildElement() public static method

Gets the name-specified child XElement of the parent XElement.
public static GetChildElement ( string name, System.Xml.Linq.XElement parent ) : System.Xml.Linq.XElement
name string The name of the child XElement to get.
parent System.Xml.Linq.XElement The parent of the child XElement to get.
return System.Xml.Linq.XElement

GetCollectionElementName() public static method

Gets the custom name of collection elements of a property. Defaults to "Element".
public static GetCollectionElementName ( PropertyInfo property ) : string
property System.Reflection.PropertyInfo The property to use.
return string

GetDictionaryElementName() public static method

Gets the custom name of collection key and value elements of a property.
public static GetDictionaryElementName ( PropertyInfo property ) : string>.KeyValuePair
property System.Reflection.PropertyInfo The property to use.
return string>.KeyValuePair

GetElementType() public static method

Gets the type of an object from its serialized XElement (e.g. if it has a type attribute) and its parent container type (e.g. if it is generic).
public static GetElementType ( System.Xml.Linq.XElement element, Type parentType, int genericArgumentIndex ) : Type
element System.Xml.Linq.XElement The XElement representing the object used to get the type.
parentType System.Type The type of the object's parent container used to check if the object is in a generic container.
genericArgumentIndex int The index of the object's type in the list of its parent container's generic arguments.
return System.Type

GetIdentifier() public static method

Gets the XML identifier of the member.
public static GetIdentifier ( MemberInfo memberInfo ) : string
memberInfo System.Reflection.MemberInfo The information about the member to use.
return string

GetIdentifier() public static method

Gets the XML identifier of the class from an object of that class.
public static GetIdentifier ( object obj ) : string
obj object The object to use.
return string

SetupSerializedElement() public static method

Formats a serialized XElement with options.
public static SetupSerializedElement ( object value, System.Xml.Linq.XElement element, XmlConvertOptions options ) : System.Xml.Linq.XElement
value object The object serialized.
element System.Xml.Linq.XElement The serialized XElement of the object.
options XmlConvertOptions Indicates how the output is formatted or serialized.
return System.Xml.Linq.XElement

ShouldIgnoreProperty() public static method

Checks if a property should not be serialized.
public static ShouldIgnoreProperty ( PropertyInfo property ) : bool
property System.Reflection.PropertyInfo The property to check.
return bool