DataContract surrogate for amplified value type

前端 未结 1 559
陌清茗
陌清茗 2021-01-15 05:17

I want to use a custom aplified type (think Nullable) in a DataContract class. I tried to write a IDataContractSurrogate but it fails at deserialization.

<
相关标签:
1条回答
  • 2021-01-15 05:54

    You cannot use surrogates for primitive types (i.e., you'll be able to convert from Amplified<T> to T when T is a primitive, but not the other direction). For a possible alternative, take a look at the section "Fine grained control of serialization format for primitives" at https://docs.microsoft.com/en-us/archive/blogs/carlosfigueira/wcf-extensibility-serialization-callbacks.

    0 讨论(0)
提交回复
热议问题