Reputation: 735
I am using a service with several endpoints divided out by their subsystem. All the systems have a set of standard objects that are used to pass structured data back and forth. In a given application, I am using three of the seven available end points. ServiceA
, ServiceB
and ServiceC
. Establishing a connect to each returns a structure of EnvironmentVariableType
, but because each comes back from a different service, C# considers them to be different types. ServiceA.EnvironmentVariableType
, ServiceB.EnvironmentVariableType
and ServiceC.EnvironmentVariableType
.
Is there a way to abstract them and treat all three as the same object type?
Upvotes: 3
Views: 95
Reputation: 39297
If you can't modify the generated code for the services to insert a common interface or to use the same types you could instead use Impromptu Interface which would allow you to take the result of each call and make it ActLike
an interface you define. It's available in Nuget.
Upvotes: 1
Reputation: 268
You need to create adapter layer via interface. Derive your own classes from this interface and each class access one service which convert service objects or types to your application local types.
Upvotes: 1