Using IXmlSerialization, how can I serialize a T property?

nicobubulle

New Member
My question is so simple.Imagine we have a Foo class. and has a T property.\[code\]public class Foo<T>{ public T Property { get; set; }}\[/code\]I want to implement in it IXmlSerializable and my problem is I have no idea to imitate the standard XmlSerialization. I really have no idea about how to write this property like the standart XmlSerlalization.UPDATE: I did this and it's not working\[code\]public class Foo<T> : IFoo where T : IXmlSerializable{ public T Value { get; set; }}public class FooA : Foo<string> { }public class FooB : Foo<int> { }public class FooC : Foo<List<Double>> { }\[/code\]When I serialized this classes (A, B and C). I wanna have something like this:Using first class:\[code\]<FooA> <Value>StringDemo</Value></FooA>\[/code\]Using second class:\[code\]<FooB> <Value>2</Value></FooB>\[/code\]Using third class:\[code\]<FooC> <Value> <ArrayOfDouble xsi:..> <Double>3.1416</Double> <Double>4.2</Double> </ArrayOfDouble> </Value></FooC>\[/code\]Something like this is what I wanted, I don't want to implement in all of this a custom XmlSerializer, I mean the default which the standard serialization use.
 
Back
Top