473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

custom serialization

Hi,
I'm new serialization concepts....I need some hwlp..
I've a class defined as follows

class CustomSerialization1
{
private string s;

public string Test
{
get { return s; }
set { s = value; }
}

private int i;

public int Test1
{
get { return i; }
set { i = value; }
}
CustomSerialization1 obj = new CustomSerialization1();
obj.Test = "vijaya,wajid,vani";
object.Test1 = 3;
}

if want the the output to be sth below after applying serializatiion

<Task>
<Test>
<TestInnner>Vijaya</TestInnner>
<TestInnner>wajid</TestInnner>
<TestInnner>vani</TestInnner>
</Test>
<Test1>3</Test3>
</Task>

Basically I want to control teh way inwhich my Test property will be
displayed during serialization and deserialization....
please help me out..just let me know if this is possible by any means...
either thru XmlSerialization or Custom Serialziation...
May 4 '07 #1
1 897
pretty trivial. you implement IXmlSerializable:

public void WriteXml(XmlWriter writer)
{
writer.WriteStartElement("Taskt");
writer.WriteStartElement("Test");
string[] values = s.Split(',');
for (int i=0; i < values.Length; ++i)
{
writer.WriteStartElement("Test1");
writer.WriteString(values[i]);
writer.WriteEndElement();
}
writer.WriteEndElement();

writer.WriteStartElement("Test1");
writer.WriteString(Test1.ToString());
writer.WriteEndElement();
writer.WriteEndElement();
}
public void ReadXml(XmlReader reader)
{
// left to reader
}

AVL wrote:
Hi,
I'm new serialization concepts....I need some hwlp..
I've a class defined as follows

class CustomSerialization1
{
private string s;

public string Test
{
get { return s; }
set { s = value; }
}

private int i;

public int Test1
{
get { return i; }
set { i = value; }
}
CustomSerialization1 obj = new CustomSerialization1();
obj.Test = "vijaya,wajid,vani";
object.Test1 = 3;
}

if want the the output to be sth below after applying serializatiion

<Task>
<Test>
<TestInnner>Vijaya</TestInnner>
<TestInnner>wajid</TestInnner>
<TestInnner>vani</TestInnner>
</Test>
<Test1>3</Test3>
</Task>

Basically I want to control teh way inwhich my Test property will be
displayed during serialization and deserialization....
please help me out..just let me know if this is possible by any means...
either thru XmlSerialization or Custom Serialziation...
May 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect...
0
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect...
3
by: Zachary Turner | last post by:
Hello, I have a situation where I would like to perform custom serialization and deserialization of an existing .NET framework object (specifically, System.DateTime). Is there a common paradigm...
4
by: Val | last post by:
I have a complex object that I need to serialize. Rather than rely on a standard routine, which is called during the serialization/deserialization, I would like to be able to use my own functions...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.