Fix up the Bootstrappers project

This commit is contained in:
Antony Male 2016-07-09 12:21:02 +01:00
parent 10c8fa4f3a
commit 3286bf087e
6 changed files with 42 additions and 16 deletions

View File

@ -31,8 +31,12 @@ namespace Bootstrappers
/// </summary>
protected virtual void DefaultConfigureIoC(ContainerBuilder builder)
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
builder.RegisterInstance<IViewManager>(viewManager);
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
builder.RegisterInstance<IViewManager>(new ViewManager(viewManagerConfig));
builder.RegisterInstance<IWindowManagerConfig>(this);
builder.RegisterType<WindowManager>().As<IWindowManager>().SingleInstance();
@ -51,7 +55,7 @@ namespace Bootstrappers
return this.container.Resolve(type);
}
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}

View File

@ -31,9 +31,13 @@ namespace Bootstrappers
/// </summary>
protected virtual void DefaultConfigureIoC(IWindsorContainer container)
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
container.Register(
Component.For<IViewManager>().Instance(viewManager),
Component.For<IViewManager>().Instance(new ViewManager(viewManagerConfig)),
Component.For<IWindowManagerConfig>().Instance(this),
Component.For<IMessageBoxViewModel>().ImplementedBy<MessageBoxViewModel>().LifestyleTransient(),
// For some reason we need to register the delegate separately?
@ -54,7 +58,7 @@ namespace Bootstrappers
return this.container.Resolve(type);
}
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}

View File

@ -29,8 +29,12 @@ namespace Bootstrappers
/// </summary>
protected virtual void DefaultConfigureIoC(IKernel kernel)
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
kernel.Bind<IViewManager>().ToConstant(viewManager);
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
kernel.Bind<IViewManager>().ToConstant(new ViewManager(viewManagerConfig));
kernel.Bind<IWindowManagerConfig>().ToConstant(this);
kernel.Bind<IWindowManager>().ToMethod(c => new WindowManager(c.Kernel.Get<IViewManager>(), () => c.Kernel.Get<IMessageBoxViewModel>(), c.Kernel.Get<IWindowManagerConfig>())).InSingletonScope();
@ -48,7 +52,7 @@ namespace Bootstrappers
return this.kernel.Get(type);
}
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}

View File

@ -19,7 +19,12 @@ namespace Bootstrappers
protected virtual void DefaultConfigureContainer()
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
var viewManager = new ViewManager(viewManagerConfig);
this.Container.Add(typeof(IViewManager), () => viewManager);
var windowManager = new WindowManager(viewManager, () => (IMessageBoxViewModel)this.Container[typeof(IMessageBoxViewModel)](), this);
@ -36,7 +41,7 @@ namespace Bootstrappers
/// </summary>
protected virtual void ConfigureContainer() { }
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}

View File

@ -32,8 +32,12 @@ namespace Bootstrappers
/// </summary>
protected virtual void DefaultConfigureIoC(ConfigurationExpression config)
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
config.For<IViewManager>().Add(viewManager);
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
config.For<IViewManager>().Add(new ViewManager(viewManagerConfig));
config.For<IWindowManagerConfig>().Add(this);
config.For<IWindowManager>().Add<WindowManager>().LifecycleIs<SingletonLifecycle>();
@ -52,7 +56,7 @@ namespace Bootstrappers
return this.container.GetInstance(type);
}
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}

View File

@ -29,7 +29,12 @@ namespace Bootstrappers
/// </summary>
protected virtual void DefaultConfigureIoC(IUnityContainer container)
{
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
var viewManagerConfig = new ViewManagerConfig()
{
ViewFactory = this.GetInstance,
ViewAssemblies = new List<Assembly>() { this.GetType().Assembly }
};
var viewManager = new ViewManager(viewManagerConfig);
// For some reason using ContainerControlledLifetimeManager results in a transient registration....
container.RegisterInstance<IViewManager>(viewManager);
container.RegisterInstance<IWindowManager>(new WindowManager(viewManager, () => container.Resolve<IMessageBoxViewModel>(), this));
@ -48,7 +53,7 @@ namespace Bootstrappers
return this.container.Resolve(type);
}
public override void Launch()
protected override void Launch()
{
base.DisplayRootView(this.RootViewModel);
}