Table of Contents

Class Serializer

Namespace
NMF.Serialization
Assembly
NMF.Serialization.dll

Denotes the base class for a serializer

public class Serializer
Inheritance
Serializer
Derived
Inherited Members

Constructors

Serializer()

Creates a new XmlSerializer with default settings and no preloaded types

public Serializer()

Serializer(Serializer)

Creates a new XmlSerializer and copies settings and known types from the given serializer

public Serializer(Serializer parent)

Parameters

parent Serializer

An XML serializer to copy settings and known type information from

Serializer(Serializer, XmlSerializationSettings)

Creates a new XmlSerializer and copies settings and known types from the given serializer

public Serializer(Serializer parent, XmlSerializationSettings settings)

Parameters

parent Serializer

An XML serializer to copy settings and known type information from

settings XmlSerializationSettings

New settings

Serializer(Serializer, XmlSerializationSettings, IEnumerable<Type>)

Creates a new XmlSerializer and copies settings and known types from the given serializer

public Serializer(Serializer parent, XmlSerializationSettings settings, IEnumerable<Type> additionalTypes)

Parameters

parent Serializer

An XML serializer to copy settings and known type information from

settings XmlSerializationSettings

New settings

additionalTypes IEnumerable<Type>

Set of types to load into the serializer

Serializer(XmlSerializationSettings)

Creates a new XmlSerializer with the specified settings

public Serializer(XmlSerializationSettings settings)

Parameters

settings XmlSerializationSettings

Serializer-settings for the serializer. Can be null or Nothing in Visual Basic. In this case, the default settings will be used.

Serializer(XmlSerializationSettings, IEnumerable<Type>)

Creates a new XmlSerializer with the specified settings and the given preloaded types

public Serializer(XmlSerializationSettings settings, IEnumerable<Type> additionalTypes)

Parameters

settings XmlSerializationSettings

The settings to use for the serializer

additionalTypes IEnumerable<Type>

Set of types to load into the serializer

Remarks

The types will be loaded with the specified settings

Serializer(IEnumerable<Type>)

Creates a new XmlSerializer with default settings

public Serializer(IEnumerable<Type> additionalTypes)

Parameters

additionalTypes IEnumerable<Type>

Set of types to preload into the serializer

Remarks

Types will be loaded with default settings

Properties

KnownTypes

The set of types that are known to the serializer

public ICollection<Type> KnownTypes { get; }

Property Value

ICollection<Type>

Settings

The settings to be used in the serializer

public XmlSerializationSettings Settings { get; }

Property Value

XmlSerializationSettings

Methods

ConvertString(string, IPropertySerializationInfo, XmlSerializationContext)

Converts the given string to a value

protected object ConvertString(string text, IPropertySerializationInfo info, XmlSerializationContext context)

Parameters

text string

the string that needs to be parsed

info IPropertySerializationInfo

the property for which the string is parsed

context XmlSerializationContext

the context in which the string is parsed

Returns

object

the parsed object

CreateAddToPropertyDelay(IPropertySerializationInfo, object, string, XmlSerializationContext)

Adds a delay to add an item to a property collection

protected static void CreateAddToPropertyDelay(IPropertySerializationInfo property, object obj, string text, XmlSerializationContext context)

Parameters

property IPropertySerializationInfo

the property for which the item is added

obj object

the target object

text string

the original text in the JSON document

context XmlSerializationContext

the context in which the deserialization is done

CreateSerializationContext(object)

Creates a serialization context for the given root element

protected virtual XmlSerializationContext CreateSerializationContext(object root)

Parameters

root object

The root element of the serialization

Returns

XmlSerializationContext

A serialization context

CreateSetPropertyDelay(IPropertySerializationInfo, object, string, XmlSerializationContext)

Adds a delay to set a property directly from a resolved text

protected static void CreateSetPropertyDelay(IPropertySerializationInfo property, object obj, string text, XmlSerializationContext context)

Parameters

property IPropertySerializationInfo

the property that should be set,

obj object

the target object

text string

the original text in the JSON document

context XmlSerializationContext

the context in which the deserialization is done

CreateTypeSerializationInfoFor(Type)

Creates the type serialization information for the given type

protected virtual ITypeSerializationInfo CreateTypeSerializationInfoFor(Type type)

Parameters

type Type

the system type for which the serialization information should be created

Returns

ITypeSerializationInfo

a type serialization info

GetAttributeValue(object, ITypeSerializationInfo, bool, XmlSerializationContext)

Gets the serialization of the given attribute value

protected virtual string GetAttributeValue(object value, ITypeSerializationInfo info, bool isCollection, XmlSerializationContext context)

Parameters

value object

The value of the attribute

info ITypeSerializationInfo

The serialization information of the type

isCollection bool

True, if the value is added to a collection, otherwise false

context XmlSerializationContext

The serialization context

Returns

string

The serialized value of the attribute

GetSerializationInfo(Type, bool)

Gets the serialization information for the given type

public ITypeSerializationInfo GetSerializationInfo(Type type, bool createIfNecessary)

Parameters

type Type

The type

createIfNecessary bool

If true, the serialization information is added if missing

Returns

ITypeSerializationInfo

The type serialization information

GetSerializationInfoForInstance(object, bool)

Gets the serialization information for the provided instance

public virtual ITypeSerializationInfo GetSerializationInfoForInstance(object instance, bool createIfNecessary)

Parameters

instance object

The instance

createIfNecessary bool

If true, the serialization information is added if missing

Returns

ITypeSerializationInfo

The type serialization information

GetTypeInfo(string, string)

Gets the type serialization info corresponding to the provided pair of namespace and local name

public ITypeSerializationInfo GetTypeInfo(string ns, string localName)

Parameters

ns string

the namespace of the type

localName string

the local name of the type

Returns

ITypeSerializationInfo

the type serialization info

HandleUnknownType(IPropertySerializationInfo, string, string)

Handles the case that the type of the element is not known

protected virtual ITypeSerializationInfo HandleUnknownType(IPropertySerializationInfo property, string ns, string localName)

Parameters

property IPropertySerializationInfo

The property for which the type was requested

ns string

The namespace at the current position

localName string

The local name of the type

Returns

ITypeSerializationInfo

The type serialization information received for this type or null, if no type could be resolved

InitializeTypeSerializationInfo(Type, ITypeSerializationInfo)

Initializes the given type serialization information for the given type

protected virtual void InitializeTypeSerializationInfo(Type type, ITypeSerializationInfo serializationInfo)

Parameters

type Type

the system type

serializationInfo ITypeSerializationInfo

the serialization information object

OnConverterException(ConverterExceptionEventArgs)

Gets called when the ConverterException event should be raised

protected virtual void OnConverterException(ConverterExceptionEventArgs eventArgs)

Parameters

eventArgs ConverterExceptionEventArgs

The event data

OnUnknownAttribute(UnknownAttributeEventArgs)

Fires the UnknownAttribute event

protected virtual void OnUnknownAttribute(UnknownAttributeEventArgs e)

Parameters

e UnknownAttributeEventArgs

the event data

OnUnknownElement(UnknownElementEventArgs)

Fires the UnknownElement event

protected virtual void OnUnknownElement(UnknownElementEventArgs e)

Parameters

e UnknownElementEventArgs

the event data

OnUnknownType(UnknownTypeEventArgs)

Handles the UnknownType event

protected virtual void OnUnknownType(UnknownTypeEventArgs e)

Parameters

e UnknownTypeEventArgs

the event data

RegisterNamespace(ITypeSerializationInfo, string)

Registers the given type serialization info for a namespace lookup

protected void RegisterNamespace(ITypeSerializationInfo info, string ns)

Parameters

info ITypeSerializationInfo

the type serialization info

ns string

the namespace for which the type should be registered

SelectRoot(object, bool)

Gets the serialization root element

protected virtual object SelectRoot(object graph, bool fragment)

Parameters

graph object

The base element that should be serialized

fragment bool

A value indicating whether only a fragment should be written

Returns

object

The root element for serialization

Events

ConverterException

Gets raised when a converter used by the serializer ran into an exception

public event EventHandler<ConverterExceptionEventArgs> ConverterException

Event Type

EventHandler<ConverterExceptionEventArgs>

UnknownAttribute

Get raised when the serializer finds an attribute that is not known

public event EventHandler<UnknownAttributeEventArgs> UnknownAttribute

Event Type

EventHandler<UnknownAttributeEventArgs>

UnknownElement

Gets raised when the serializer finds an element that is not known

public event EventHandler<UnknownElementEventArgs> UnknownElement

Event Type

EventHandler<UnknownElementEventArgs>

UnknownType

Gets raised when the serializer finds a type that is not known

public event EventHandler<UnknownTypeEventArgs> UnknownType

Event Type

EventHandler<UnknownTypeEventArgs>