Skip to content

Commit

Permalink
Add comments and code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Dec 3, 2023
1 parent b0b27dc commit c86a4ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
| OSS | 支持 | 极简化更新,是一套独立的更新机制。只需要在文件服务器中放置version.json的版本配置文件。组件会根据配置文件中的版本信息进行更新下载。(支持Windows,MAUI Android) |
| 回滚 | 待测试 | 逐版本更新时会备份每个版本,如果更新失败则逐版本回滚。 |
| 驱动更新 | 待测试 | 逐版本更新时会备份每个版本的驱动文件(.inf),如果更新失败则逐版本回滚。 |
| 系统服务 | 待测试 | 开机时和升级时会检查升级是否成功,如果失败则根据遗言还原之前的备份。遗言是更新之前就已经自动创建在C:\generalupdate_willmessages目录下的will_message.json文件。will_message.json的内容是持久化回滚备份的文件目录相关信息。(需要部署GeneralUpdate.SystemService系统服务) |
| 遗言 | 待测试 | 开机时和升级时会检查升级是否成功,如果失败则根据遗言还原之前的备份。遗言是更新之前就已经自动创建在C:\generalupdate_willmessages目录下的will_message.json文件。will_message.json的内容是持久化回滚备份的文件目录相关信息。(需要部署GeneralUpdate.SystemService系统服务) |
| 自定义方法列表 | 待测试 | 注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境) |


Expand Down
4 changes: 2 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
| Skip updates | yes | Support injection pop-up window allows users to decide whether to update this release, and the update will not take effect when the server decides to force it. |
| Upgrade each other | yes | The main program updates the upgrade program, and the upgrade program updates the main program. |
| Black list | yes | Files and file extensions from the blacklist are skipped during the update process. |
| OSS(MAUI) | yes | Minimal updates require only the version configuration file of version.json to be placed on the file server. Components are updated and downloaded based on the version information in the configuration file.(Supported windows,MAUI Android) |
| OSS | yes | Minimal updates require only the version configuration file of version.json to be placed on the file server. Components are updated and downloaded based on the version information in the configuration file.(Supported windows,MAUI Android) |
| Restore | test | Each version is backed up during a version-by-version update and rolled back version-by-version if the update fails. |
| Driver upgrade | test | The driver file (.INF) of each version is backed up during the version-by-version update and is rolled back version-by-version if the update fails. |
| System service | test | The upgrade is checked for success at boot and upgrade, and if it fails, the previous backup is restored according to the last word. The last word is that the will_message.json file in the C:\generalupdate_willmessages directory was automatically created before the update. will_message.json is about the file directory of the persistent rollback backup.(need to deploy GeneralUpdate. SystemService system service) |
| Will message | test | The upgrade is checked for success at boot and upgrade, and if it fails, the previous backup is restored according to the last word. The last word is that the will_message.json file in the C:\generalupdate_willmessages directory was automatically created before the update. will_message.json is about the file directory of the persistent rollback backup.(need to deploy GeneralUpdate. SystemService system service) |
| A list of custom methods | test | Inject a custom collection of methods that are executed before the update starts. Execute a custom method list, and if there are any exceptions, you will be notified by exception subscription.(It is recommended to check the current software environment before updating) |


Expand Down
8 changes: 8 additions & 0 deletions src/c#/GeneralUpdate.Client/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,26 @@ private void Upgrade()
.Option(UpdateOption.DownloadTimeOut, 60)
.Option(UpdateOption.Encoding, Encoding.Default)
.Option(UpdateOption.Format, Format.ZIP)
//开启驱动更新
.Option(UpdateOption.Drive, true)
//开启遗言功能,需要部署GeneralUpdate.SystemService Windows服务。
.Option(UpdateOption.WillMessage, true)
.Strategy<WindowsStrategy>()
//注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效
.SetCustomSkipOption(ShowCustomOption)
//注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境)
.AddCustomOption(new List<Func<bool>>() { ()=> Check1(), () => Check2() })
//默认黑名单文件: { "Newtonsoft.Json.dll" } 默认黑名单文件扩展名: { ".patch", ".7z", ".zip", ".rar", ".tar" , ".json" }
//如果不需要扩展,需要重新传入黑名单集合来覆盖。
.SetBlacklist(GetBlackFiles(), GetBlackFormats())
.LaunchTaskAsync();
});
}

private bool Check1() => true;

private bool Check2() => true;

private List<string> GetBlackFiles()
{
var blackFiles = new List<string>();
Expand Down

0 comments on commit c86a4ea

Please sign in to comment.