New to Telerik UI for WinFormsStart a free 30-day trial

Provides XML serialization functionality for components using the same rules as Visual Studio Code DOM serialization.

Definition

Constructors

Initializes a new instance of the ComponentXmlSerializer class with default serialization settings.

C#
public ComponentXmlSerializer()

Initializes a new instance of the ComponentXmlSerializer class with extended property serialization information.

C#
public ComponentXmlSerializer(ComponentXmlSerializationInfo componentSerializationInfo)
Parameters:componentSerializationInfoComponentXmlSerializationInfo

Extended property serialization information for customizing serialization behavior.

Initializes a new instance of the ComponentXmlSerializer class with custom type mapping and serialization information.

C#
public ComponentXmlSerializer(IDictionary typeMap, ComponentXmlSerializationInfo componentSerializationInfo)
Parameters:typeMapIDictionary

Dictionary mapping type full names to XML element names for custom serialization.

componentSerializationInfoComponentXmlSerializationInfo

Extended property serialization information for customizing serialization behavior.

Properties

C#
public virtual InstanceFactory InstanceFactory { get; set; }

Gets or sets the properties provider used for custom property handling during serialization.

C#
public IPropertiesProvider PropertiesProvider { get; set; }
Property Value:

The properties provider instance.

Gets or sets a value indicating whether the serializer will search only Telerik assemblies for type resolution.

C#
public bool ResolveTypesOnlyInTelerikAssemblies { get; set; }
Property Value:

true to search only Telerik assemblies; false to search all domain assemblies.

Gets the root object being serialized or deserialized.

C#
public object RootSerializationObject { get; }
Property Value:

The root serialization object.

Methods

C#
protected virtual void DisposeObject(IDisposable toBeDisposed)
Parameters:toBeDisposedIDisposable
C#
protected virtual IEnumerable GetCollectionElementOverride(IEnumerable list, object owner, PropertyDescriptor property)
Parameters:listIEnumerableownerobjectpropertyPropertyDescriptorReturns:

IEnumerable

C#
protected virtual string GetElementNameByType(Type elementType)
Parameters:elementTypeTypeReturns:

string

C#
protected virtual object GetPropertyValue(PropertyDescriptor property, object propertyOwner)
Parameters:propertyPropertyDescriptorpropertyOwnerobjectReturns:

object

C#
protected virtual void InitializeRead()
C#
protected virtual void InitializeWrite()
C#
protected virtual object MatchExistingItem(XmlReader reader, IList toRead, object parent, PropertyDescriptor parentProperty, string propertyToMatch, string uniquePropertyValue, IList existingInstancesToMatch, ref int foundAtIndex)
Parameters:readerXmlReadertoReadIListparentobjectparentPropertyPropertyDescriptorpropertyToMatchstringuniquePropertyValuestringexistingInstancesToMatchIListfoundAtIndexintReturns:

object

Matches the instance of the element by an attribute value and then deserializes its properties. If the instance is not found in existingInstancesToMatch, new instance of type instanceType will be created and added to existingInstancesToMatch list.

C#
protected virtual object MatchObjectElement(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string propertyToMatch, IList existingInstancesToMatch, out int foundAtIndex)
Parameters:readerXmlReaderparentobjectparentPropertyPropertyDescriptortoReadIListpropertyToMatchstringexistingInstancesToMatchIList

the list with existing instances

foundAtIndexint

index of the element if found in existingInstanceToMatch

Returns:

object

Override to provide custom processing of collection being deserialized

C#
protected virtual bool ProcessListOverride(XmlReader reader, object listOwner, PropertyDescriptor ownerProperty, IList list)
Parameters:readerXmlReaderlistOwnerobjectownerPropertyPropertyDescriptorlistIListReturns:

bool

True if the list does not require further processing by the deserializer, False to use the default deserialization

C#
protected virtual bool ProcessProperty(PropertyDescriptor property)
Parameters:propertyPropertyDescriptorReturns:

bool

Reads a property of an object and subobject the reader is currently positioned on.

C#
protected virtual bool ProcessReaderAttribute(XmlReader reader, object parentObject, object toRead, PropertyDescriptor property)
Parameters:readerXmlReader

Xml reader instance, positioned on the element to read.

parentObjectobject

The parent object instance, null if there is no parent object information

toReadobject

The object instance to be processed

propertyPropertyDescriptor

The property that is being processed. Extracted from reader.Name

Returns:

bool

A value indicating whether the attribute has been processed. If [true] the parent class will not process current property/attribute.

C#
protected virtual bool ProcessTypeOverride(Type type, XmlReader reader, PropertyDescriptor property, object toRead)
Parameters:typeTypereaderXmlReaderpropertyPropertyDescriptortoReadobjectReturns:

bool

Reads a collection element from the XML reader and populates the specified list.

C#
public void ReadCollectionElement(XmlReader reader, IList toRead)
Parameters:readerXmlReader

The XML reader positioned at a collection element.

toReadIList

The list to populate with deserialized items.

Reads a collection element from the XML reader and populates the specified list with disposal options.

C#
public void ReadCollectionElement(XmlReader reader, object collectionOwner, IList toRead, bool disposeObjects)
Parameters:readerXmlReader

The XML reader positioned at a collection element.

collectionOwnerobject

The object that owns the collection property being deserialized.

toReadIList

The list to populate with deserialized items.

disposeObjectsbool

Whether to dispose objects during deserialization.

Reads a collection element from the XML reader and populates the specified list with an owner context.

C#
public void ReadCollectionElement(XmlReader reader, object collectionOwner, IList toRead)
Parameters:readerXmlReader

The XML reader positioned at a collection element.

collectionOwnerobject

The object that owns the collection property being deserialized.

toReadIList

The list to populate with deserialized items.

C#
protected void ReadDictionaryElement(XmlReader reader, object dictionaryOwner, IDictionary toRead)
Parameters:readerXmlReaderdictionaryOwnerobjecttoReadIDictionary

Deserializes a specified property of an object

C#
protected virtual void ReadElementInObject(XmlReader reader, PropertyDescriptor property, object toRead)
Parameters:readerXmlReader

Xml reader, positioned on the element corresponding to the property to deserialize

propertyPropertyDescriptor

Property descriptor of the property to deserialize

toReadobject

Object that owns the property to deserialize

if Reader is positioned at an element that is a collection, reads the collection items.

C#
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName, bool preserveNotSerializedExistingElements, bool disposeObjects)
Parameters:readerXmlReaderparentobjectparentPropertyPropertyDescriptortoReadIListuniquePropertyNamestring

property used to match objects in collection

preserveNotSerializedExistingElementsbool

States whether the list specified by toRead should not be cleared before reading

disposeObjectsbool

Reads the collection items if reader is positioned on an element that is a collection.

C#
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName, bool disposeObjects)
Parameters:readerXmlReaderparentobjectparentPropertyPropertyDescriptortoReadIListuniquePropertyNamestring

property used to match objects in collection

disposeObjectsbool

Reads the collection items if reader is positioned on an element that is a collection.

C#
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName)
Parameters:readerXmlReaderparentobjectparentPropertyPropertyDescriptortoReadIListuniquePropertyNamestring

property used to match objects in collection

Reads properties of an object and subobject the reader is currently positioned on.

C#
public void ReadObjectElement(XmlReader reader, object parentObject, object toRead)
Parameters:readerXmlReader

Xml reader instance, positioned on the element to read.

parentObjectobject

parent object instance, null if there is no parent object information

toReadobject

object instance to be processed

Reads properties of an object and subobject the reader is currently positioned on.

C#
public void ReadObjectElement(XmlReader reader, object toRead)
Parameters:readerXmlReader

Xml reader instance, positioned on the element to read.

toReadobject

object instance to be processed

Override to provide alternative deserialization of objects.

C#
protected virtual bool ReadObjectElementOverride(XmlReader reader, object toRead)
Parameters:readerXmlReadertoReadobjectReturns:

bool

value indicating whether the object should be processed any further by serializer

C#
protected virtual void SetPropertyValue(PropertyDescriptor property, object propertyOwner, object value)
Parameters:propertyPropertyDescriptorpropertyOwnerobjectvalueobject

Provides logic to determine whether property value should be serialized.

C#
protected virtual bool ShouldSerializeValue(object component, PropertyDescriptor property, PropertySerializationMetadata overwriteMetadata)
Parameters:componentobjectpropertyPropertyDescriptor

property to serialize

overwriteMetadataPropertySerializationMetadata

collection of extra serialization attributes for the property, corresponding to ComponentSerializationInfo

Returns:

bool

value indicating whether property value should be serialized

Remarks:

ShouldSerialize value resolution is as follows:

C#
protected virtual void WriteCollectionElement(XmlWriter writer, IEnumerable list, object listOwner, PropertyDescriptor property)
Parameters:writerXmlWriterlistIEnumerablelistOwnerobjectpropertyPropertyDescriptor
C#
public void WriteCollectionElement(XmlWriter writer, IEnumerable list, string collectionName)
Parameters:writerXmlWriterlistIEnumerablecollectionNamestring
C#
protected void WriteDictionaryElement(XmlWriter writer, IDictionary toWrite, object listOwner, PropertyDescriptor property)
Parameters:writerXmlWritertoWriteIDictionarylistOwnerobjectpropertyPropertyDescriptor

Serializes the given object using the specified XmlWriter.

C#
public virtual void WriteObjectElement(XmlWriter writer, object toWrite)
Parameters:writerXmlWritertoWriteobject
C#
protected virtual bool WritePropertyOverride(XmlWriter writer, PropertyDescriptor property, object propertyValue, DesignerSerializationVisibility serializationVisibility)
Parameters:writerXmlWriterpropertyPropertyDescriptorpropertyValueobjectserializationVisibilityDesignerSerializationVisibilityReturns:

bool

C#
protected virtual void WriteTypeAttribute(XmlWriter writer, Type expectedType, object toWrite, DesignerSerializationVisibility serializationVisibility)
Parameters:writerXmlWriterexpectedTypeTypetoWriteobjectserializationVisibilityDesignerSerializationVisibility
In this article
DefinitionConstructorsComponentXmlSerializer()ComponentXmlSerializer(ComponentXmlSerializationInfo)ComponentXmlSerializer(IDictionary, ComponentXmlSerializationInfo)PropertiesInstanceFactoryPropertiesProviderResolveTypesOnlyInTelerikAssembliesRootSerializationObjectMethodsDisposeObject(IDisposable)GetCollectionElementOverride(IEnumerable, object, PropertyDescriptor)GetElementNameByType(Type)GetPropertyValue(PropertyDescriptor, object)InitializeRead()InitializeWrite()MatchExistingItem(XmlReader, IList, object, PropertyDescriptor, string, string, IList, ref int)MatchObjectElement(XmlReader, object, PropertyDescriptor, IList, string, IList, out int)ProcessListOverride(XmlReader, object, PropertyDescriptor, IList)ProcessProperty(PropertyDescriptor)ProcessReaderAttribute(XmlReader, object, object, PropertyDescriptor)ProcessTypeOverride(Type, XmlReader, PropertyDescriptor, object)ReadCollectionElement(XmlReader, IList)ReadCollectionElement(XmlReader, object, IList, bool)ReadCollectionElement(XmlReader, object, IList)ReadDictionaryElement(XmlReader, object, IDictionary)ReadElementInObject(XmlReader, PropertyDescriptor, object)ReadMergeCollection(XmlReader, object, PropertyDescriptor, IList, string, bool, bool)ReadMergeCollection(XmlReader, object, PropertyDescriptor, IList, string, bool)ReadMergeCollection(XmlReader, object, PropertyDescriptor, IList, string)ReadObjectElement(XmlReader, object, object)ReadObjectElement(XmlReader, object)ReadObjectElementOverride(XmlReader, object)SetPropertyValue(PropertyDescriptor, object, object)ShouldSerializeValue(object, PropertyDescriptor, PropertySerializationMetadata)WriteCollectionElement(XmlWriter, IEnumerable, object, PropertyDescriptor)WriteCollectionElement(XmlWriter, IEnumerable, string)WriteDictionaryElement(XmlWriter, IDictionary, object, PropertyDescriptor)WriteObjectElement(XmlWriter, object)WritePropertyOverride(XmlWriter, PropertyDescriptor, object, DesignerSerializationVisibility)WriteTypeAttribute(XmlWriter, Type, object, DesignerSerializationVisibility)
Not finding the help you need?
Contact Support