1

I have created a pretty complicated app using some sort of "factory" design pattern. That way, i have interface defining a class, i have a class implementing the interface and i have a static class with static method for creating an instance. That static method (factory method) returns interface type, and only factory class can access my type class. So, if i have private class A, i'll have public interface IA and static factory class Factory. "Factory" class is the only one that can access "A", and it returns type "IA". That way, entire project is working using interfaces (for example "IA"), passing interfaces as arguments and so long. Simply put, my app is NEVER using class "A" except in factory class.

Now, the tricky part - i have decided to split my app to client and server part. Those to parts will communicate using WCF. But i have a problem - with WCF i can't use interfaces as return types / arguments like i did in WHOLE CODE SO FAR.

Please is there ANY way to make my project work without changing the very base of my "know-only-interface" code?

guest86
  • 2,894
  • 8
  • 49
  • 72
  • Can you give code example of your WCF usage? – Amittai Shapira Aug 15 '11 at 13:26
  • Well not really, because i have 3 projects inside one solution, it would be too complicated :\ One project is client code (mostyle user interface), another is ClassLib with types shared by client and wcf, and third project is wcf service library... – guest86 Aug 15 '11 at 13:28

1 Answers1

2

Create a class with the same properties as in the interface IA. You can specify the return type of the service operation to be the type of this class. In the service operation, create an object (DTO) of this class and map the values from the object of type IA. Now you can just return this DTO.

Kiran Mothe
  • 685
  • 5
  • 10