If you return this type as a field in another class, you can simply use a surrogate property, for example:
public TreeId Id { get; set; } [DataMember(Name = "Id")] private string IdSurrogate { get { return Id.ToString(); } set { Id = new TreeId(value); } }
Thus, instead of putting the DataContract in the TreeId class, the IdSurrogate property simply processes it directly on the string value
source share