Apply IOperationBehavior override for plain serialization? (not service)
I would like to create an [CustomDataMember]
attribute that override the formatter behavior of DataContractSerializer
through an IOperationBehavior
. I have followed the instructions given by Aaron Skonnard but when I call the DCS serializer, the custom behavior does not get neither instantiated nor called.
Obviously, I am missing something, probably at the level of the constructor call of DataContractSerializer
. Does anyone knows what cou开发者_运维问答ld be done to get the behavior properly injected in the DCS?
Aaron's instructions don't apply. Those instructions are for switching which serializer WCF uses when dealing with message conversion. You're instantiating the serializer directly. DataContractSerializer doesn't really support much customization of the process- it's supposed to be dirt simple, not flexible. If you need flexibility, use XmlSerializer/IXmlSerializable.
精彩评论