Skip to content

Instantly share code, notes, and snippets.

@blazey
Created June 18, 2015 10:43
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 blazey/b959af307923eebae028 to your computer and use it in GitHub Desktop.
Save blazey/b959af307923eebae028 to your computer and use it in GitHub Desktop.
Bootstrap example
public class Bootstrap : IDisposable
{
private readonly Lazy<IWindsorContainer> _container = new Lazy<IWindsorContainer>(() =>
{
var container = new WindsorContainer();
container.Install(FromAssembly.This());
container.Register(Component.For<IWindsorContainer>().Instance(container));
return container;
});
public IWindsorContainer Container
{
get { return _container.Value; }
}
public void AddFacility<TFacility>(Action<TFacility> onCreate) where TFacility : IFacility, new()
{
Container.AddFacility(onCreate);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Container.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment