Last active
August 29, 2015 14:19
-
-
Save bitbonk/db2c01a5b32a219c0185 to your computer and use it in GitHub Desktop.
Minimal Calibrun.Micro Bootstrapper Implementation that uses TinyIoC
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Windows; | |
using Caliburn.Micro; | |
using TinyIoC; | |
public class TinyBootstrapper : BootstrapperBase | |
{ | |
private TinyIoCContainer container; | |
public TinyBootstrapper() | |
{ | |
this.Initialize(); | |
} | |
protected override void BuildUp(object instance) | |
{ | |
this.container.BuildUp(instance); | |
} | |
protected override void Configure() | |
{ | |
this.container = new TinyIoCContainer(); | |
this.container.AutoRegister(); | |
} | |
protected override IEnumerable<object> GetAllInstances(Type service) | |
{ | |
return this.container.ResolveAll(service, true); | |
} | |
protected override object GetInstance(Type service, string key) | |
{ | |
return string.IsNullOrWhiteSpace(key) | |
? this.container.Resolve(service) | |
: this.container.Resolve(service, key); | |
} | |
protected override void OnStartup(object sender, StartupEventArgs e) | |
{ | |
this.DisplayRootViewFor<ShellViewModel>(); | |
} | |
protected override IEnumerable<Assembly> SelectAssemblies() | |
{ | |
return base.SelectAssemblies().Concat( | |
new[] { typeof(ShellViewModel).Assembly }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment