Does anyone have a good example of a bootstrapper class I can see for reference..
I can't seem to find one anywhere, searched google but no luck.
Searched the helpfile and no luck..
Does anyone have a good example of a bootstrapper class I can see for reference..
I can't seem to find one anywhere, searched google but no luck.
Searched the helpfile and no luck..
If you are searching for a class that that configures the container at the beggining of an application, you can download the latest Prism drop and look for the UnityBootstrapper class.
Take into account that this is only registering the necessary services for a Prism application to run, so your bootstrapper will probably require a different container configuration.
You can find another example in the WPF:MVVM & Unity Kiosk sample project. Here the Bootsrapper class:
public class Bootstrapper
{
public Bootstrapper(IUnityContainer container)
{
this.container = container;
}
public Bootstrapper RegisterModule(Type moduleType)
{
IModule module = container.Resolve(moduleType) as IModule;
if (module == null)
throw new ArgumentException("moduleType");
module.Register(container);
return this;
}
private IUnityContainer container;
}
And the IModule interface:
public interface IModule
{
void Register(IUnityContainer container);
}
Finally, One of the implemented Modules:
public class PhotoEditorModule : IModule
{
public void Register(IUnityContainer container)
{
// register default controller
container.RegisterType<IPhotoEditor, Controller>();
// register view models
container.RegisterType<IPhotoEditorViewModel, PhotoEditorViewModel>();
container.RegisterType<IPhotoEditorMenuViewModel, PhotoEditorMenuViewModel>();
}
}