Question about SimpleContainer

Topics: Bootstrappers & IoC
Feb 23, 2013 at 9:33 PM
Edited Feb 24, 2013 at 8:23 PM
There is a Nuget Package Caliburn.Micro.Container which I've tried to use in a WPF application, but I just get a error.
See GetInstance for my comment.
(Caliburn.Micro 1.4.1, VS2012, .Net 4.5)

Is this Bootstrapper right?

EDIT:
I've got it working now. I forgot to change Bootstrapper<ShellViewModel> to Bootstrapper<IShellViewModel>
So I've edited below to the working solution.


namespace WpfApplication1
{
public class AppBootstrapper : Bootstrapper<IShellViewModel> 
{
    SimpleContainer _container;

    public AppBootstrapper()
    {
    }

    protected override void Configure()
    {
        _container = new SimpleContainer();

        base.Configure();

        _container.RegisterSingleton(typeof(IWindowManager), null, typeof(WindowManager));
        _container.RegisterSingleton(typeof(IShellViewModel), null, typeof(ShellViewModel));
    }

    protected override object GetInstance(Type service, string key)
 {       
      //Do not call
      //base.GetInstance(service, key);

        var inst = _container.GetInstance(service, key);
        return inst;
    }

    protected override System.Collections.Generic.IEnumerable<object> GetAllInstances(Type service)
    {
        return _container.GetAllInstances(service);
    }

    protected override void BuildUp(object instance)
    {
        _container.BuildUp(instance);
    }
}
}