Prism code sample learning: 01-BootstrapperShell
Prism code sample learning: 01-BootstrapperShell
What is Prism
See below.
https://www.fenet.jp/dotnet/column/tool/1715/
Among the above, it seems that the following are the main features.
–Assistant to ViewModel implementation
–DI container (dependency injection)
- InteractionRequest
- EventAggregator
Introduction
This article is an article created by referring to the following code.
I would like to understand not only how to make it using Prism, but also how the library is made.
Please note that the sample seems to have legacy code left, and some classes have the Obsolute attribute.
01-BootstrapperShell
In this sample, it seems that the application is launched using a class called Bootstrapper.
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
}
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
}
Is it the following as a point?
–Prism library assets are registered in Bootstrapper
–As a property, it has a Container of type IUnityContainer as a member, which serves as a DI container.
–You can see what is being injected by looking at here Easy (when using the default configuration)
–CreateShell () registers the application’s shell or main window, and InitializeShell () is called in the Rum () method.
As a promise of Prism, it seems important to write in Bootstrap what you need at startup.
As for each module, it seems that we will learn from the following samples, so we will stop here.
in conclusion
This time I read the Bootstrapper class that registers the Prism library assets at startup.
Next time, I’ll look at 02-Regions.