I have one interface and two classes (implemented from that interface) in my application as below:
public interface ISMSServiceProvider
{
NotificationSentResponse Send(SMSMessage sms);
}
public class NexmoProvider: ISMSServiceProvider
{
NotificationSentResponse Send(SMSMessage sms);
}
public class TwilioProvider: ISMSServiceProvider
{
NotificationSentResponse Send(SMSMessage sms);
}
At some places in my application I need to use NexmoProvider, and at some places TwilioProvider. That's been decided based on the value of a variable of following enum:
public enum NotificationProvider
{
Twilio = 1,
Nexmo = 2
}
I am using service stack in my application, and having following code to resolve the dependency:
container.RegisterAutoWiredAs<TwilioProvider, ISMSServiceProvider>();
But as you can see there is nothing in ISMSServiceProvider that would allow me to register two different types at the same time.
Could anyone please suggest what changes I may need to do in below structure to enable me using either of Nexmo or Twilio provider classes at runtime?