Coppermill
Coppermill

Reputation: 6794

My Interface and external Webserver

I have an external Web Service that returns back its own object, and I would like to get it to compile to my interfaces is this possible?

(IGetPerson)testAPI.GetPersons();

Where testAPI is the external web service

testAPI.GetPerson returns webservice.GetCarResponse, which is of course from the external webservice.

I need to get the results to fit in to my interfaces so I can use IoC

Any ideas?

Upvotes: 1

Views: 58

Answers (2)

Adam
Adam

Reputation: 943

Could you have a class that wraps whatever class the webservice returns and implements your interface? The implementation of each property of the interface would simply return or set the corresponding value on the webservice's response object (which would be stored as an instance variable)

The adapter pattern (wikipedia)

Upvotes: 1

RichardOD
RichardOD

Reputation: 29157

Sounds like a candidate for the Adapter Pattern to me. Have a look at the example provided by doFactory.

Upvotes: 2

Related Questions