It is possible that several classes implement the same interface with the structure structure.
If you name your mappings, you can later load them with that name.
For<MyInterface>().Add<Class1ForMyInterface>().Named("Class1"); For<MyInterface>().Add<Class2ForMyInterface>().Named("Class2");
If you want your Class1ForMyInterface you can call
container.GetInstance<MyInterface>("Class1");
There are also several ways to display all this in your container, and
For<IController>().Add<Controller1>().Ctor<MyInterface>().Is(i => i.GetInstance<MyInterface>("Class1"));
Or, if you save the smartinsatance property, which is returned when the type is registered, you can use it in the mapping.
var class1 = For<MyInterface>().Add<Class1ForMyInterface>().Named("Class1"); For<IController>().Add<Controller1>().Ctor<MyInterface>().Is(class1);
Bassetassen
source share