我应该创建什么而不是引导程序?棱镜 6.1.0
What should I create instead of Bootstrapper? Prism 6.1.0
我尝试将我的应用程序从 Prism v4.0 更新到 Prism v6.1.0 和 运行 包管理器:
PM> 安装包 Prism.Core
并且 PM 已经安装了这样的软件包:
- Microsoft.Practices.Prism.Composition.dll
- Microsoft.Practices.Prism.Interactivity.dll
- Microsoft.Practices.Prism.Mvvm.dll
- Microsoft.Practices.Prism.Mvvm.Desktop.dll
- Microsoft.Practices.Prism.PubSubEvents.dll
- Microsoft.Practices.Prism.SharedInterfaces.dll
- Microsoft.Practices.ServiceLocation.dll
我尝试创建引导程序的下一步:
public class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IShellViewModel, ShellViewModel>();
}
protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
mappings.RegisterMapping(typeof(StackPanel), Container.Resolve<StackPanelRegionAdapter>());
return mappings;
}
protected override IModuleCatalog CreateModuleCatalog()
{
ModuleCatalog catalog = new ModuleCatalog();
catalog.AddModule(typeof(ModuleBModule));
return catalog;
}
}
我已经尝试解决 UnityBootstrapper
。但是,Prism 6.1.0 中没有这样的 class。
所以我尝试通过 Nuget 安装:
Prism.UnityExtesions
但是 NuGet 说:This package is no longer supported. Please use the new Prism.Unity package
.
Prism 5.0 有一个引导程序 class。但现在不支持 Prism 5.0。例如,在此示例中 HelloWorld 来自 code.msdn。
所以我想到了这个问题:如何在 Prism 6.1.0 上创建引导程序?
正如@toumir 在评论中提到的,首先卸载所有 Microsoft.Practices.*
包(检查你的 packages.config 以确保它们都已卸载)。
由于您尝试将 Unity 与 Prism 6 一起使用,因此您必须安装的 唯一 包是 Prism.Unity。这将自动引入所有其他需要的包:
- 团结
- CommonServiceLocator
- Prism.Wpf
- Prism.Core
最好只添加最具体的包,因为新的项目文件(.NET Core,ASP.NET 5,Win10 UWP)旧的 packages.config 文件被替换为project.json 文件和 NuGet v3 将处理 better dependency resolving。到今天它还没有用于 WPF,但这不应该阻止你这样做 "right"。
对于 Prism 6 上的新 documentation and samples,请前往 Prism GitHub 存储库。
我尝试将我的应用程序从 Prism v4.0 更新到 Prism v6.1.0 和 运行 包管理器: PM> 安装包 Prism.Core
并且 PM 已经安装了这样的软件包:
- Microsoft.Practices.Prism.Composition.dll
- Microsoft.Practices.Prism.Interactivity.dll
- Microsoft.Practices.Prism.Mvvm.dll
- Microsoft.Practices.Prism.Mvvm.Desktop.dll
- Microsoft.Practices.Prism.PubSubEvents.dll
- Microsoft.Practices.Prism.SharedInterfaces.dll
- Microsoft.Practices.ServiceLocation.dll
我尝试创建引导程序的下一步:
public class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IShellViewModel, ShellViewModel>();
}
protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
mappings.RegisterMapping(typeof(StackPanel), Container.Resolve<StackPanelRegionAdapter>());
return mappings;
}
protected override IModuleCatalog CreateModuleCatalog()
{
ModuleCatalog catalog = new ModuleCatalog();
catalog.AddModule(typeof(ModuleBModule));
return catalog;
}
}
我已经尝试解决 UnityBootstrapper
。但是,Prism 6.1.0 中没有这样的 class。
所以我尝试通过 Nuget 安装:
Prism.UnityExtesions
但是 NuGet 说:This package is no longer supported. Please use the new Prism.Unity package
.
Prism 5.0 有一个引导程序 class。但现在不支持 Prism 5.0。例如,在此示例中 HelloWorld 来自 code.msdn。
所以我想到了这个问题:如何在 Prism 6.1.0 上创建引导程序?
正如@toumir 在评论中提到的,首先卸载所有 Microsoft.Practices.*
包(检查你的 packages.config 以确保它们都已卸载)。
由于您尝试将 Unity 与 Prism 6 一起使用,因此您必须安装的 唯一 包是 Prism.Unity。这将自动引入所有其他需要的包:
- 团结
- CommonServiceLocator
- Prism.Wpf
- Prism.Core
最好只添加最具体的包,因为新的项目文件(.NET Core,ASP.NET 5,Win10 UWP)旧的 packages.config 文件被替换为project.json 文件和 NuGet v3 将处理 better dependency resolving。到今天它还没有用于 WPF,但这不应该阻止你这样做 "right"。
对于 Prism 6 上的新 documentation and samples,请前往 Prism GitHub 存储库。