XmlSerializer: Inheritance and Read-Only Properties



All,

Please maximize for easier viewing. Assume I have a class structure as
follows:

[Serializable]
public class Foo
{
private string _hello = "Hello";

public string Hello
{
get
{
return _hello;
}
}
}

public class Bar : Foo
{
private Foo _fooBar = new Foo();
private string _message = "This is a test";

public Foo FooBar
{
get
{
return _fooBar;
}
}

public string Message
{
get
{
return _message;
}
set
{
_message = value;
}
}
}

When serializing an instance of Bar using the XmlSerializer, I only see the
property named "Message" in my resulting XML string. How can I tell the
XmlSerializer to include all of Bar including read-only properties and all
of Foo (it's base class) in the resulting XML?

Kindest Regards,
Michael




.



Relevant Pages


Loading