Commit e378cb74 authored by 潘栩锋's avatar 潘栩锋 🚴

Install2 项目

1. 优化 Application.Current.Properties 改为 容器 Resolve,RegisterInstance 方式
2. 优化 当程序可以升级,自动选择 【升级】
parent 991d4799
......@@ -13,5 +13,21 @@ namespace Install
/// </summary>
public partial class App : Application
{
public static T Resolve<T>()
{
return (T)App.Current.Properties[typeof(T).FullName];
}
public static T Resolve<T>(string name)
{
return (T)App.Current.Properties[typeof(T).FullName + $".{name}"];
}
public static void RegisterInstance<T>(T obj)
{
App.Current.Properties[typeof(T).FullName] = obj;
}
public static void RegisterInstance<T>(T obj, string name)
{
App.Current.Properties[typeof(T).FullName + $".{name}"] = obj;
}
}
}
......@@ -42,8 +42,10 @@ namespace Install
return;
}
Application.Current.Properties[nameof(InstallWizard)] = installWizard;
Application.Current.Properties["NavigationService"] = NavigationService;
//注入
App.RegisterInstance(installWizard);
App.RegisterInstance(NavigationService);
Pg1st p = new Pg1st();
p.Init();
NavigationService.Navigate(p);
......
......@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.0.1")]
[assembly: AssemblyFileVersion("4.0.1")]
[assembly: Guid("AB127AC6-16C6-411F-8892-D90413A863C8")]
......@@ -28,7 +28,7 @@ namespace Install.View
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
this.DataContext = installWizard;
}
......
......@@ -50,7 +50,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Icons = installWizard.Icons;
......@@ -103,7 +103,7 @@ namespace Install.View
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
await installWizard.Install(InstallPath, installPacks);
}
}
......
......@@ -30,7 +30,7 @@ namespace Install.View
}
public void Init()
{
installWizard = App.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
this.DataContext = installWizard;
installWizard.PropertyChanged += InstallWizard_PropertyChanged;
......
......@@ -57,7 +57,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Icons = installWizard.Icons;
......@@ -66,13 +66,16 @@ namespace Install.View
Items.Add(new ListItem() { Item = installInfo, IsSelected = installInfo.NeedToUpdate });
}
if (installWizard.HasInstalled.Count(installInfo => installInfo.NeedToUpdate) > 0)
Option = OPTION.UPDATE;
HasNew = installWizard.ToInstall.Count > 0;
}
private void New()
{
PgInstall p = new PgInstall();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
}
private async void Next()
......@@ -86,7 +89,7 @@ namespace Install.View
}
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
App.Resolve<NavigationService>().Navigate(p);
switch (Option)
{
......
......@@ -64,7 +64,7 @@ namespace Install.View
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
installWizard = App.Resolve<InstallWizard>();
Msg = $"下载 {installWizard.NewestInstallZipVersionInfo.InstallZipUrl}";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment