Bootstrapper Class for Caliburn.Micro with SimpleContainer as IoC Container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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