Re: XmlSerializer: Inheritance and Read-Only Properties



Please disregard as it seems I'll need to implement the IXmlSerializable
interface. If anyone has other options then please let me know.

- m

"Michael Primeaux" <mjprimeaux@xxxxxxxxxxxxxx> wrote in message
news:%238NDemhHGHA.3144@xxxxxxxxxxxxxxxxxxxxxxx
> 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