Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bootstrapper Class for Caliburn.Micro with SimpleContainer as IoC Container
public class SCBootstrapper:BootstrapperBase
{
private readonly SimpleContainer _Container = new SimpleContainer();
public SCBootstrapper()
{
Initialize();
}
protected override void Configure()
{
_Container.Singleton<IWindowManager, WindowManager>();
_Container.Singleton<IEventAggregator, EventAggregator>();
_Container.PerRequest<IShell, ShellViewModel>();
}
protected override object GetInstance(Type service, string key)
{
var instance = _Container.GetInstance(service, key);
if (instance != null)
return instance;
throw new InvalidOperationException("Could not locate any instances.");
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return _Container.GetAllInstances(service);
}
protected override void BuildUp(object instance)
{
_Container.BuildUp(instance);
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<IShell>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment