Reputation: 8962
Is it possible specify which constructor the WCF serialization engine uses when deserializing a data member?
For example: I want to use this constructor to make a case-insensitive dictionary without creating a new class that inherits from Dictionary.
[DataMember]
Dictionary<string, string> Values { get; set; }
// Values should be created with this constructor
new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
Upvotes: 1
Views: 884
Reputation: 12135
If you provide an implementation of your property setter method, you can instantiate for yourself the new case-insensitive Dictionary instance which will be the value of the property, and just copy into it the items from the instance provided by the serializer as the value
parameter.
You'll need to be prepared to handle any exceptions due to key clashes if the source of the serialized Dictionary was case-sensitive.
Upvotes: 3
Reputation: 1038710
Is it possible specify which constructor the WCF serialization engine uses when deserializing a data member?
No it isn't, unless you use implement your custom serialization.
Upvotes: 2