We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I serialize classes in Edit control?

 

The class XmlSerializersCreator can be used to create serializers for classes used by Edit Control. The steps to create serializers are given below.

1.Create an application configuration file with the following lines.

[XML]

2.Create an instance of the class XmlSerializersCreator using its constructor with three parameters: location of the output files, namespace that has to be assigned to the newly created classes, and list of Type class instances containing types for which serializers should be created.

C#

string filePath = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\CS\";

array=new ArrayList ();

array.AddRange(new Type[]{typeof(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem),typeof(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage),typeof(Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format),typeof(Syncfusion.Windows.Forms.Edit.Enums.KnownLanguages),typeof(Syncfusion.Windows.Forms.Edit.Enums.OutliningTooltipShowMode)});

xmlserializer=new Syncfusion.XmlSerializersCreator.XmlSerializersCreator(filePath,"XMLSerialization",array);

xmlserializer.CreateSerializers();

VB

Private filePath As String = Path.GetDirectoryName(Application.ExecutablePath) + "\..\..\VB\"

array = New ArrayList ()

array.AddRange(New Type(){GetType(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem),GetType(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage),GetType(Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format),GetType(Syncfusion.Windows.Forms.Edit.Enums.KnownLanguages),GetType(Syncfusion.Windows.Forms.Edit.Enums.OutliningTooltipShowMode)})

xmlserializer = New Syncfusion.XmlSerializersCreator.XmlSerializersCreator(filePath, "XMLSerialization", array)

xmlserializer.CreateSerializers()

3.Add the newly created files to the project and rebuild it.

4.The static method of the SerializersManager class GetSerializer( Type type ) is used to search calling assembly for custom serializers and if custom serializers are found, instance of SerializerWrapper is returned, otherwise standard XmlSerializer is created.

C#

XmlSerializer serializewrapper1=SerializersManager.GetSerializer(typeof(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem));

XmlSerializer serializewrapper2=SerializersManager.GetSerializer(typeof(Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format));

XmlSerializer serializewrapper3=SerializersManager.GetSerializer(typeof(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage));

VB

Dim serializewrapper1 As XmlSerializer=SerializersManager.GetSerializer(GetType(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem))

Dim serializewrapper2 As XmlSerializer=SerializersManager.GetSerializer(GetType(Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format))

Dim serializewrapper3 As XmlSerializer=SerializersManager.GetSerializer(GetType(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage))

5.Use the Deserialize method of the SerializerWrapper to restore the object's state.

C#

FileStream formatreader = new FileStream("..\\..\\Format.xml", FileMode.Open);

FileStream configlexemreader = new FileStream("..\\..\\configlexem.xml", FileMode.Open);

Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format deserializedformat = (Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format) serializewrapper2.Deserialize(formatreader);

Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem deserializedconfiglexem=(Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem)serializewrapper1.Deserialize(configlexemreader);

VB

Dim formatreader As FileStream = New FileStream("..\..\Format.xml", FileMode.Open)

Dim configlexemreader As FileStream = New FileStream("..\..\configlexem.xml", FileMode.Open)

Dim deserializedformat As Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format = CType(serializewrapper2.Deserialize(formatreader), Syncfusion.Windows.Forms.Edit.Implementation.Formatting.Format)

Dim deserializedconfiglexem As Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem=CType(serializewrapper1.Deserialize(configlexemreader), Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLexem)

Please refer to the attached sample for further information.

Article ID: Published Date: Last Revised Date: Platform: Control:
389 04/30/2011 07/10/2014 WinForms EditControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon