Why this deserialized throws me StackOverflow exception?

Pete

New Member
When I try to deserialized my FooContainer (List) throws me an error. Please, just watch the last part of this code.\[code\]public interface IFoo{ object Value { get; }}public abstract class Foo<T> : IFoo{ [XmlElement("Value")] public T Value { get; set; } [XmlIgnore] object IFoo.Value { get { return Value; } }}public class FooA : Foo<string> { }public class FooB : Foo<int> { }public class FooC : Foo<List<Double>> { }[XmlRoot("Foos")]public class FooContainer : List<IFoo>, IXmlSerializable{ public XmlSchema GetSchema() { throw new NotImplementedException(); } public void ReadXml(XmlReader reader) { XmlSerializer serial = new XmlSerializer(typeof(FooContainer)); serial.Deserialize(reader); } public void WriteXml(XmlWriter writer) { ForEach(x => { XmlSerializer serial = new XmlSerializer(x.GetType(), new Type[] { typeof(FooA), typeof(FooB), typeof(FooC) }); serial.Serialize(writer, x); }); }}class Program{ static void Main(string[] args) { FooContainer fooList = new FooContainer() { new FooA() { Value = "http://stackoverflow.com/questions/10441391/String" }, new FooB() { Value = http://stackoverflow.com/questions/10441391/2 }, new FooC() { Value = new List<double>() {2, 3.4 } } }; XmlSerializer serializer = new XmlSerializer(fooList.GetType(), new Type[] { typeof(FooA), typeof(FooB), typeof(FooC) }); System.IO.TextWriter textWriter = new System.IO.StreamWriter(@"C:\temp\movie.xml"); serializer.Serialize(textWriter, fooList); textWriter.Close(); XmlReader reader = XmlReader.Create(@"C:\temp\movie.xml"); var a = serializer.Deserialize(reader); }}\[/code\]What am I doing wrong?
 
Back
Top