-
-
Notifications
You must be signed in to change notification settings - Fork 144
NinjectBootstrapper
Antony Male edited this page Aug 2, 2014
·
3 revisions
This is an example bootstrapper which uses Ninject.
class NinjectBootstrapper : BootstrapperBase<MyRootViewModel>
{
private IKernel kernel;
protected override void Configure()
{
base.Configure();
this.kernel = new StandardKernel();
// These can go into a module
// You must bind IWindowManager and IViewManager
this.kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
this.kernel.Bind<IViewManager>().To<ViewManager>().InSingletonScope();
// IEventAggregator is optional
this.kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
// MessageBoxViewModel is required to use IWindowManager.ShowMessageBox
this.kernel.Bind<IMessageBoxViewModel>().To<MessageBoxViewModel>(); // Not singleton!
}
protected override object GetInstance(Type service, string key)
{
return string.IsNullOrEmpty(key) ? this.kernel.Get(service) : this.kernel.Get(service, key);
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return this.kernel.GetAll(service);
}
protected override void BuildUp(object instance)
{
this.kernel.Inject(instance);
}
}
- Introduction
- Quick Start
- Bootstrapper
- ViewModel First
- Actions
- The WindowManager
- MessageBox
- The EventAggregator
- PropertyChangedBase
- Execute: Dispatching to the UI Thread
- Screens and Conductors
- BindableCollection
- Validation using ValidatingModelBase
- StyletIoC
- The ViewManager
- Listening to INotifyPropertyChanged
- Design Mode Support
- Logging
- Misc