I want to register all my types implementing IManager so that they can be used as the type T for the generic Lazy<T> class.
For example:
public TetraRadioPropertyUpdater(Lazy<IRadioManager> lazyRadioManager)
I use a self made scanner because my concrete types and interfaces are internal and therefor I cannot use the built in StructureMap scan mechanism.
In the first statement of the loop register all my IManager types like For<IRadioManager>().Singleton().Use<RadioManager>()
As well, I want them to be registered so that they can be used as the generic type for Lazy<T> like For<Lazy<IRadioManager>().Use<Lazy<RadioManger>>()
InterfaceScanner<IManager> interfaceScanner = new InterfaceScanner<IManager>();
// managerMapping looks like:
// { IRadioManager, RadioManager }
// { ICallManager, CallManager }
// .. more manager interface to plugin type pairs
foreach (KeyValuePair<Type, Type> managerMapping in interfaceScanner.Process())
{
// the key is the plugin type, value is the concrete type
For(managerMapping.Key).Singleton().Use(managerMapping.Value);
// something like this.. ?
For(typeof(Lazy<>)).Singleton().Use(c => new Lazy(() => c.GetInstance(managerMapping.Value)));
}
Is this possible? How do I need to configure it for StructureMap?