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.
You cannot use surrogates for primitive types (i.e., you'll be able to convert from Amplified
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.