SimpleContainer. Build instances with container.AllTypesOf

Topics: Bootstrappers & IoC
Dec 9, 2013 at 10:18 AM

I think I do not understand the function of SimpleContainer.
I have additional assemblies with my services which should be injected into the viewmodels etc.
I'hab added the assembly in the AppBootstrapper like the following:
protected override void Configure()
    container = new SimpleContainer();

    container.Singleton<IWindowManager, WindowManager>();
    container.Singleton<IEventAggregator, EventAggregator>();
All Services are implemting the interface IService.
After the line with AllTypesOf<IService> is succeded, I could the the entries of my services with the debugger. But in in every entry, the property Singleton is null.

When using now such a service in the constructor of a viewmodel, the parameter still is null
public class ShellViewModel
    private readonly IMyDataService _service;
    private readonly IWindowManager _windowmanager;

    public ShellViewModel(IMyDataService dataService, IWindowManager windowManager)
        _service = dataService; // is null
        _windowmanager = windowManager; // has an instance
Is there something, I did wrong? How could I use the injection functionality?
Dec 10, 2013 at 7:21 AM
Edited Dec 10, 2013 at 7:33 AM
is there any metadata associated with IService?
            .PerRequest<IAirline, xxxHttpScrape>()
            .PerRequest<IAirline, xxxSkedParser>()
            .PerRequest<IAirline, xxxCCSParser>();
One thing I haven't tried though was to pull them in via DI, IoC.GetAll<IAirline>() works just fine.

the only difference on the IAirline interface is that I have 2 string fields that are used in each of the implementations to indicate the airline and use of the implementation.

To be honest I hadn't ever used that instantiation option with SimpleContainer yet.

Have you tried _service = IoC.GetInstance<IMyDataService>() and not used DI in this case?

lastly is services.dll added as a reference ?