Skip to content

Instantly share code, notes, and snippets.

@bitbonk
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbonk/db2c01a5b32a219c0185 to your computer and use it in GitHub Desktop.
Save bitbonk/db2c01a5b32a219c0185 to your computer and use it in GitHub Desktop.
Minimal Calibrun.Micro Bootstrapper Implementation that uses TinyIoC
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