Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: SimpleContainer. Build instances with container.AllTypesOf

$
0
0
Hello,

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>();
    container.PerRequest<ShellViewModel>();
    container.AllTypesOf<IService>(Assembly.LoadFrom("Services.dll"));
}
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?

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>