Consider the following
builder.Register(c => new A());
builder.Register(c => new B());
builder.Register(c => new C());
B
Clarification for any one searching this with regards to Inherited Class
Ex :
public static IEnumerable GetTypesInherit(this Assembly assembly)
{
var types = assembly.GetTypes()
.Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T)))
.ToList();
return types;
}
Installer :
public static IContainer Install()
{
var builder = new ContainerBuilder();
var executingAssembly = Assembly.GetExecutingAssembly();
var testScreens = executingAssembly.GetTypesInherit();
foreach (var testScreen in testScreens)
{
builder.RegisterType(testScreen).As();
}
var container = builder.Build();
return container;
}
Usage (Implicit) :
public class MainViewModel(IEnumerable testScreens)
{}