This project has moved and is read-only. For the latest updates, please go here.

Include a property from a base class, when the derived class is MemberSerialization.OptIn?

Jan 12, 2011 at 7:19 PM

I have a custom exception class that derives from System.Exception.  I don't want to include everything from the base Exception class, so my CustomException class uses MemberSerialization.OptIn.  So the properties in my custom class have JsonProperty attributes to include them, but is there a way to selectively include certain properties from the base System.Exception class as well?

Jan 12, 2011 at 8:17 PM

Figured it out.  Turns out that the Data member is virtual, so I just had to override it like this:

// Overridden so I can tag it with the JsonProperty attribute


public override System.Collections.IDictionary Data { get { return base.Data; } }


Still, I wonder how you'd go about it with something that's not virtual, or something that's private even.  Maybe not possible with OptIn?