So far this is the best I have come up with:
I have an internal string Extension method:
internal static class DeserializationHelper
{
internal static DateTime GetDeserializedDateTime(this string @string)
{
if (string.IsNullOrEmpty(@string)) return default(DateTime);
//insert complex custom deserialization logic here
return DateTime.Parse(@string);
}
}
This is the DataMember setup:
[DataMember(Name = "lastmodified")]
internal string _LastModified
{
set { LastModified = value.GetDeserializedDateTime(); }
//getter is not needed for receiving data but WCF requires one
get { return default(string); }
}
public DateTime LastModified { get; private set; }
If you wanted to use this DataContract for sending data (make this a writeable Property), you would have to write a DateTime Extension method (GetSerializedDateString), expand the setters/getters and introduce private members as go-betweens.
It smells of cut and paste, and it does not take advantage of any WCF framework features. What would Bill Gates do?