Use multi-binding in bootstrapper

This commit is contained in:
Antony Male 2015-10-03 16:58:27 +01:00
parent df7e024bf5
commit 764cfe0b39
2 changed files with 3 additions and 2 deletions

View File

@ -51,8 +51,7 @@ namespace Stylet
var viewManager = new ViewManager(this.GetInstance, new List<Assembly>() { this.GetType().Assembly });
// Bind it to both IViewManager and to itself, so that people can get it with Container.Get<ViewManager>()
builder.Bind<ViewManager>().ToInstance(viewManager).AsWeakBinding();
builder.Bind<IViewManager>().ToInstance(viewManager).AsWeakBinding();
builder.Bind<IViewManager>().And<ViewManager>().ToInstance(viewManager).AsWeakBinding();
builder.Bind<IWindowManagerConfig>().ToInstance(this).AsWeakBinding();
builder.Bind<IWindowManager>().To<WindowManager>().InSingletonScope().AsWeakBinding();

View File

@ -52,6 +52,8 @@ namespace StyletUnitTests
Assert.IsInstanceOf<WindowManager>(ioc.Get<IWindowManager>());
Assert.IsInstanceOf<IEventAggregator>(ioc.Get<IEventAggregator>());
Assert.IsInstanceOf<ViewManager>(ioc.Get<IViewManager>());
Assert.IsInstanceOf<ViewManager>(ioc.Get<ViewManager>());
Assert.IsInstanceOf<MessageBoxViewModel>(ioc.Get<IMessageBoxViewModel>());
// Test autobinding
Assert.DoesNotThrow(() => ioc.Get<RootViewModel>());