1

I'm am working with the WCF and I have a composite Type. I want to make a DataContract with that complex type and its data members. Normally I would do something like this :

[DataContract]
public class CompositeType
{
    bool boolValue = true;
    string stringValue = "Hello ";

    [DataMember]
    public bool BoolValue
    {
        get { return boolValue; }
        set { boolValue = value; }
    }

    [DataMember]
    public string StringValue
    {
        get { return stringValue; }
        set { stringValue = value; }
    }
}

However, how do you form a data contract if you cannot modify the declaration. For example, the original class comes from a dll.

I considered making a class that wraps around the type with properties that would act as getters and setters. I could then put the contract on the wrapper class' properties but I was wonder if there was actually a way to do this.

Aelphaeis
  • 2,593
  • 3
  • 24
  • 42

0 Answers0