Don't force user to call base.ConfigureIoC when overriding Bootstrapper<T>

This commit is contained in:
Antony Male 2014-04-22 12:04:03 +01:00
parent 9da35d85fb
commit f538c55391
1 changed files with 15 additions and 11 deletions

View File

@ -29,28 +29,32 @@ namespace Stylet
var builder = new StyletIoCBuilder(); var builder = new StyletIoCBuilder();
// Mark these as auto-bindings, so the user can replace them if they want this.DefaultConfigureIoC(builder);
builder.BindWeak(typeof(IWindowManager)).To<WindowManager>().InSingletonScope();
builder.BindWeak(typeof(IEventAggregator)).To<EventAggregator>().InSingletonScope();
builder.BindWeak(typeof(IViewManager)).To<ViewManager>().InSingletonScope();
this.ConfigureIoC(builder); this.ConfigureIoC(builder);
this.container = builder.BuildContainer(); this.container = builder.BuildContainer();
} }
/// <summary> /// <summary>
/// Override to add your own types to the IoC container. /// Carries out default configuration of StyletIoC. Override if you don't want to do this
/// </summary> /// </summary>
/// <remarks> /// <param name="builder">StyletIoC builder to use to configure the container</param>
/// Don't call the base method if you don't want to auto-self-bind all concrete types protected virtual void DefaultConfigureIoC(StyletIoCBuilder builder)
/// </remarks>
/// <param name="builder"></param>
protected virtual void ConfigureIoC(IStyletIoCBuilder builder)
{ {
// Mark these as auto-bindings, so the user can replace them if they want
builder.BindWeak(typeof(IWindowManager)).To<WindowManager>().InSingletonScope();
builder.BindWeak(typeof(IEventAggregator)).To<EventAggregator>().InSingletonScope();
builder.BindWeak(typeof(IViewManager)).To<ViewManager>().InSingletonScope();
builder.Autobind(AssemblySource.Assemblies); builder.Autobind(AssemblySource.Assemblies);
} }
/// <summary>
/// Override to add your own types to the IoC container.
/// </summary>
/// <param name="builder">StyletIoC builder to use to configure the container</param>
protected virtual void ConfigureIoC(IStyletIoCBuilder builder) { }
/// <summary> /// <summary>
/// Override which uses StyletIoC as the implementation for IoC.Get /// Override which uses StyletIoC as the implementation for IoC.Get
/// </summary> /// </summary>