Wcf datacontract for classes in a library that I cannot change

Hi, I have a class library that executes methods and has many different classes that it uses as parameters for method calls ... I create a wcf wrapper for this class library. but I don’t have permission to change the class library.

now my question is how can I expose these classes as data contracts / datamembers easily ..?

I have about 100 different classes that I need for these methods.

thank

+3
source share
4 answers

, , , WCF, - - . .

, , .

- t4 ( VS 2008 ) T4 Toolbox, . , , - . , .

, , , - . - ildasm, il , WCF, ilasm. , , , , , IP- , , , .

* *

:

public class ToWrap {
  public String Name { get; set; }
  public String Address { get; set; }
}

[DataContract]
public class Wrapper {
  private ToWrap _wrapped;

  // constructor for WCF marshalling
  public Wrapper() {
    _wrapped = new ToWrap();
  }

  public Wrapper(ToWrap wrapped) {
    _wrapped = wrapped;
  }

  [DataMember]
  public String Name {
    get { return _wrapped.Name; }
    set { _wrapped.Name = value; }
  }

  [DataMember]
  public String Address {
    get { return _wrapped.Address; }
    set { _wrapped.Address = value; }
  }
}
+2

[Serializable], WCF ServiceContract, , . , , , .

+1

.Net 3.5 SP1, DataContract. ServiceContract.

, , DataContract .

+1

, .

-2

All Articles