Skip to content

Instantly share code, notes, and snippets.

@anuviswan
Last active September 4, 2019 12:32
Show Gist options
  • Save anuviswan/971fa5a549e9ec903a48ef5fc7f572dd to your computer and use it in GitHub Desktop.
Save anuviswan/971fa5a549e9ec903a48ef5fc7f572dd to your computer and use it in GitHub Desktop.
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