Here's the scenario (public attributes, etc. omitted for brevity):
class Base
{
}
class Derived : Base
{
}
class Container : List<Base>
{
}
class Something
{
Container Contents = new Container();
}
//...
Something thing = new Something();
thing.Contents. Add(new Derived());
XmlSerializer serializer = new XmlSerializer(t ypeof(Something ));
serializer.Seri alize(destinati onFile, thing);
What I need to do is to force the serialization of the container types
as type Base, I don't want Derived in the xml. Is there a way to do this?
class Base
{
}
class Derived : Base
{
}
class Container : List<Base>
{
}
class Something
{
Container Contents = new Container();
}
//...
Something thing = new Something();
thing.Contents. Add(new Derived());
XmlSerializer serializer = new XmlSerializer(t ypeof(Something ));
serializer.Seri alize(destinati onFile, thing);
What I need to do is to force the serialization of the container types
as type Base, I don't want Derived in the xml. Is there a way to do this?
Comment