Dependency injection w. multiple implementations
I have the class package
with a type, plus more info not relevant to the question
public class Package
{
public string Type { get; set; }
// ... more package properties
}
I have the following interface service to mail packages
public interface IMailService
{
public Task<string> SendPackage(Package package);
}
Then I have several implementations for this interface
public class MailNewPackageService : IMailService
{
public async Task<string> SendPackage(Package package)
{
Console.WriteLine("send package through new service");
// implementation ...
}
}
public class MailOldPackageService : IMailService
{
public async Task<string> SendPackage(Package package)
{
Console.WriteLine("send package through old service");
// implementation ...
}
}