Provides XML serialization functionality for components using the same rules as Visual Studio Code DOM serialization.
Definition
Namespace:Telerik.WinControls.XmlSerialization
Assembly:Telerik.WinControls.dll
Syntax:
public class ComponentXmlSerializer
Inheritance: objectComponentXmlSerializer
Derived Classes:
Constructors
Initializes a new instance of the ComponentXmlSerializer class with default serialization settings.
public ComponentXmlSerializer()
Initializes a new instance of the ComponentXmlSerializer class with extended property serialization information.
public ComponentXmlSerializer(ComponentXmlSerializationInfo componentSerializationInfo)
Extended property serialization information for customizing serialization behavior.
Initializes a new instance of the ComponentXmlSerializer class with custom type mapping and serialization information.
public ComponentXmlSerializer(IDictionary typeMap, ComponentXmlSerializationInfo componentSerializationInfo)
Dictionary mapping type full names to XML element names for custom serialization.
componentSerializationInfoComponentXmlSerializationInfoExtended property serialization information for customizing serialization behavior.
Properties
public virtual InstanceFactory InstanceFactory { get; set; }
Gets or sets the properties provider used for custom property handling during serialization.
public IPropertiesProvider PropertiesProvider { get; set; }
The properties provider instance.
Gets or sets a value indicating whether the serializer will search only Telerik assemblies for type resolution.
public bool ResolveTypesOnlyInTelerikAssemblies { get; set; }
true to search only Telerik assemblies; false to search all domain assemblies.
Gets the root object being serialized or deserialized.
public object RootSerializationObject { get; }
The root serialization object.
Methods
protected virtual void DisposeObject(IDisposable toBeDisposed)
protected virtual IEnumerable GetCollectionElementOverride(IEnumerable list, object owner, PropertyDescriptor property)
protected virtual object GetPropertyValue(PropertyDescriptor property, object propertyOwner)
protected virtual void InitializeRead()
protected virtual void InitializeWrite()
protected virtual object MatchExistingItem(XmlReader reader, IList toRead, object parent, PropertyDescriptor parentProperty, string propertyToMatch, string uniquePropertyValue, IList existingInstancesToMatch, ref int foundAtIndex)
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.
protected virtual object MatchObjectElement(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string propertyToMatch, IList existingInstancesToMatch, out int foundAtIndex)
the list with existing instances
foundAtIndexintindex of the element if found in existingInstanceToMatch
Returns:Override to provide custom processing of collection being deserialized
protected virtual bool ProcessListOverride(XmlReader reader, object listOwner, PropertyDescriptor ownerProperty, IList list)
True if the list does not require further processing by the deserializer, False to use the default deserialization
protected virtual bool ProcessProperty(PropertyDescriptor property)
Reads a property of an object and subobject the reader is currently positioned on.
protected virtual bool ProcessReaderAttribute(XmlReader reader, object parentObject, object toRead, PropertyDescriptor property)
Xml reader instance, positioned on the element to read.
parentObjectobjectThe parent object instance, null if there is no parent object information
toReadobjectThe object instance to be processed
propertyPropertyDescriptorThe property that is being processed. Extracted from reader.Name
Returns:A value indicating whether the attribute has been processed. If [true] the parent class will not process current property/attribute.
protected virtual bool ProcessTypeOverride(Type type, XmlReader reader, PropertyDescriptor property, object toRead)
Reads a collection element from the XML reader and populates the specified list with disposal options.
public void ReadCollectionElement(XmlReader reader, object collectionOwner, IList toRead, bool disposeObjects)
The XML reader positioned at a collection element.
collectionOwnerobjectThe object that owns the collection property being deserialized.
toReadIListThe list to populate with deserialized items.
disposeObjectsboolWhether to dispose objects during deserialization.
Reads a collection element from the XML reader and populates the specified list with an owner context.
public void ReadCollectionElement(XmlReader reader, object collectionOwner, IList toRead)
The XML reader positioned at a collection element.
collectionOwnerobjectThe object that owns the collection property being deserialized.
toReadIListThe list to populate with deserialized items.
protected void ReadDictionaryElement(XmlReader reader, object dictionaryOwner, IDictionary toRead)
Deserializes a specified property of an object
protected virtual void ReadElementInObject(XmlReader reader, PropertyDescriptor property, object toRead)
Xml reader, positioned on the element corresponding to the property to deserialize
propertyPropertyDescriptorProperty descriptor of the property to deserialize
toReadobjectObject that owns the property to deserialize
if Reader is positioned at an element that is a collection, reads the collection items.
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName, bool preserveNotSerializedExistingElements, bool disposeObjects)
property used to match objects in collection
preserveNotSerializedExistingElementsboolStates whether the list specified by toRead should not be cleared before reading
disposeObjectsboolReads the collection items if reader is positioned on an element that is a collection.
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName, bool disposeObjects)
property used to match objects in collection
disposeObjectsboolReads the collection items if reader is positioned on an element that is a collection.
protected void ReadMergeCollection(XmlReader reader, object parent, PropertyDescriptor parentProperty, IList toRead, string uniquePropertyName)
property used to match objects in collection
Reads properties of an object and subobject the reader is currently positioned on.
protected virtual void SetPropertyValue(PropertyDescriptor property, object propertyOwner, object value)
Provides logic to determine whether property value should be serialized.
protected virtual bool ShouldSerializeValue(object component, PropertyDescriptor property, PropertySerializationMetadata overwriteMetadata)
property to serialize
overwriteMetadataPropertySerializationMetadatacollection of extra serialization attributes for the property, corresponding to ComponentSerializationInfo
Returns:value indicating whether property value should be serialized
ShouldSerialize value resolution is as follows:
protected virtual void WriteCollectionElement(XmlWriter writer, IEnumerable list, object listOwner, PropertyDescriptor property)
public void WriteCollectionElement(XmlWriter writer, IEnumerable list, string collectionName)
protected void WriteDictionaryElement(XmlWriter writer, IDictionary toWrite, object listOwner, PropertyDescriptor property)
protected virtual bool WritePropertyOverride(XmlWriter writer, PropertyDescriptor property, object propertyValue, DesignerSerializationVisibility serializationVisibility)
protected virtual void WriteTypeAttribute(XmlWriter writer, Type expectedType, object toWrite, DesignerSerializationVisibility serializationVisibility)