I have services that are derived from the same interface.
public interface IService { }
public class ServiceA : IService { }
public class ServiceB : IService
My solution for what it's worth... considered switching to Castle Windsor as can't say I liked any of the solutions above. Sorry!!
public interface IStage : IStage { }
public interface IStage {
void DoSomething();
}
Create your various implementations
public class YourClassA : IStage {
public void DoSomething()
{
...TODO
}
}
public class YourClassB : IStage { .....etc. }
Registration
services.AddTransient, YourClassA>()
services.AddTransient, YourClassB>()
Constructor and instance usage...
public class Whatever
{
private IStage ClassA { get; }
public Whatever(IStage yourClassA)
{
ClassA = yourClassA;
}
public void SomeWhateverMethod()
{
ClassA.DoSomething();
.....
}