Hi everyone,
if I have an interface marked as ServiceContract, and some method marked as OperationContract.
After that I have 2 classes implementing that interface and two different behaviours for a method in the interface.
How we can specify which implmentation we need to use when we hit that endpoint?
[ServiceContract] public interface IServiceContract { [OperationContract] void SomeMethod(); } public class ImplementationClassA : IServiceContract { public void SomeMethod() { // Implementation for Class A } } public class ImplementationClassB : IServiceContract { public void SomeMethod() { // Implementation for Class B } }
Like
1 comments
17:35 Sep 01, 2023
Hello,
Do you have the possibility to create an instance of ClassA or ClassB when calling the service (based on some input parameters) and call the SomeMethod method from the correspondent class instance? It will call the method implemented in the correspondent class and your task will be achieved.
Show all comments