This project has moved. 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 6: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 7: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?