How can I force .NET\'s XmlSerializer to add an xsi:type=\"FooClass\" to a member/node of type FooClass?
The scenario
I had no trouble producing the following:
Hello
5
from
[XmlInclude(typeof(FooClass))]
//[XmlType(TypeName = "FooBase", Namespace = "urn:namespace", IncludeInSchema = true)]
public class FooBaseClass
{
public string FooPropertyA { get; set; }
}
//[XmlType(TypeName = "Foo", Namespace = "urn:namespace", IncludeInSchema = true)]
public class FooClass : FooBaseClass
{
public int FooPropertyB { get; set; }
}
public class BazClass
{
public FooBaseClass Foo { get; set; }
}
(note the XmlType attributes are commented out. I wanted to see what happened if a namespace was specified)
Please show the code you used, and the XML it produced.