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

Opt-in & DataContract/DataMember

Mar 31, 2011 at 8:46 AM

I want to use an opt-in serialization with DataContract/DataMember attributes. However, every public instance properties are serialized?!

Looking quickly at the source code, i've found that the DefaultContractResolver keeps every 'defaultMembers' event if they do not have any attribute: those members are found based on the DefaultMembersSearchFlags property which is BindingFlags.Public | BindingFlags.Instance.

So, if i'm not wrong, it would mean that i need to 1) provide a custom contract resolver or 2) modify the DefaultMembersSearchFlags ?


Mar 31, 2011 at 10:19 AM

I'm wrong! My problem is because my class is ISerializable... so, i just need to find how to bypass this.