tags:

views:

25

answers:

0

I have an interface

IThirdPartyInterface

which I cannot modify. Some class which implements this interface drives a robot which I'm writing some software for. I pass an instance of this class into a manager that I'm writing, which gets assigned to a variable with the same type as the interface and the manager takes care of the rest.

My development machine (for some reason known only to itself) has some kind of hardware issue with the robot which means I need to run the robot on another machine, but I want my dev machine to think it is just talking to the robot normally so I want to use WCF to facilitate the communication between the two machines.

The problem is that

IThirdPartyInterface

needs to be augmented with a

ServiceContract

attribute, and each of its methods need to be augmented with an

OperationContract

attribute before WCF will have anything to do with it. Obviously I could just stick a wrapper around the third party interface, do all of my testing with that and then rename the wrapper interface to the original name when I come to ship the software, but I would rather not as it seems a bit dirty.

Specifically on the client side I want to do something like this:

 // IThirdPartyInterfaceServiced is a wrapper aroud IThirdPartyInterface
 // augmented with the necessary attributes
 var httpFactory =
    new ChannelFactory<IThirdPartyInterfaceServiced>(
      new BasicHttpBinding(),         
      new EndpointAddress(
        "http://localhost:8000/Robot"));

  IThirdPartyInterface httpProxy = httpFactory.CreateChannel();

  httpProxy.DoStuff(); // Note this fails because IThirdPartyInterface doesn't
                       // have a ServiceContract attribute.

Any ideas?