Mini Dependency Injection Container?
public class MyContainer
{
private Dictionary<Type, Type> map = new();
public void Register<TInterface, TImplementation>()
{
map[typeof(TInterface)] = typeof(TImplementation);
}
public TInterface Resolve<TInterface>()
{
var impl = map[typeof(TInterface)];
return (TInterface)Activator.CreateInstance(impl);
}
}