From 855ce6721b709c06c0b3b06264bca2a2e5462692 Mon Sep 17 00:00:00 2001 From: justerzhu Date: Sun, 10 Nov 2024 22:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=91=BD=E5=90=8D=E7=A9=BA?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c#/GeneralUpdate.Bowl/Bowl.cs | 10 +- src/c#/GeneralUpdate.Client/Program.cs | 5 +- .../GeneralClientBootstrap.cs | 2 +- .../GeneralClientOSS.cs | 2 +- .../Pipeline/PatchMiddleware.cs | 2 +- .../Strategys/WindowsStrategy.cs | 2 +- .../Download/DownloadManager.cs | 1 - src/c#/GeneralUpdate.Common/File/FileNode.cs | 147 ----------------- .../{File => FileBasic}/BlackListManager.cs | 2 +- .../{File => FileBasic}/ComparisonResult.cs | 2 +- .../FileBasic/FileNode.cs | 150 ++++++++++++++++++ .../{File => FileBasic}/FileTree.cs | 2 +- .../{File => FileBasic}/GeneralFileManager.cs | 2 +- .../Shared/Object/GlobalConfigInfo.cs | 2 + .../Driver/DriverCommand.cs | 2 +- .../Driver/RestoreDriverCommand.cs | 2 +- .../GeneralUpdateBootstrap.cs | 9 +- .../Pipeline/DriverMiddleware.cs | 7 + .../Pipeline/PatchMiddleware.cs | 2 +- .../Strategys/OSSStrategy.cs | 2 +- .../Strategys/WindowsStrategy.cs | 3 +- .../DifferentialCore.cs | 2 +- .../GeneralUpdate.Differential.csproj | 2 - src/c#/GeneralUpdate.Upgrad/Program.cs | 65 +++++++- 24 files changed, 252 insertions(+), 175 deletions(-) delete mode 100644 src/c#/GeneralUpdate.Common/File/FileNode.cs rename src/c#/GeneralUpdate.Common/{File => FileBasic}/BlackListManager.cs (98%) rename src/c#/GeneralUpdate.Common/{File => FileBasic}/ComparisonResult.cs (96%) create mode 100644 src/c#/GeneralUpdate.Common/FileBasic/FileNode.cs rename src/c#/GeneralUpdate.Common/{File => FileBasic}/FileTree.cs (99%) rename src/c#/GeneralUpdate.Common/{File => FileBasic}/GeneralFileManager.cs (99%) diff --git a/src/c#/GeneralUpdate.Bowl/Bowl.cs b/src/c#/GeneralUpdate.Bowl/Bowl.cs index 9e2bc1ea..25d84697 100644 --- a/src/c#/GeneralUpdate.Bowl/Bowl.cs +++ b/src/c#/GeneralUpdate.Bowl/Bowl.cs @@ -17,7 +17,7 @@ public Bowl(MonitorParameter parameter = null) _strategy!.SetParameter(parameter); } - private void CreateStrategy() + private Bowl CreateStrategy() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -30,6 +30,8 @@ private void CreateStrategy() if (_strategy == null) throw new PlatformNotSupportedException("Unsupported operating system"); + + return this; } public Bowl SetParameter(MonitorParameter parameter) @@ -41,5 +43,9 @@ public Bowl SetParameter(MonitorParameter parameter) return this; } - public void Launch() => _strategy.Launch(); + public Bowl Launch() + { + _strategy.Launch(); + return this; + } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs index 8892ff06..354cecb4 100644 --- a/src/c#/GeneralUpdate.Client/Program.cs +++ b/src/c#/GeneralUpdate.Client/Program.cs @@ -4,6 +4,7 @@ using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Bootstrap; using GeneralUpdate.Common.Shared.Object; +using GeneralUpdate.Differential; namespace GeneralUpdate.Client { @@ -11,7 +12,7 @@ internal class Progra { private static void Main(string[] args) { - /*Task.Run(async () => + Task.Run(async () => { var source = @"D:\packet\app"; var target = @"D:\packet\release"; @@ -19,7 +20,7 @@ private static void Main(string[] args) await DifferentialCore.Instance?.Clean(source, target, patch); await DifferentialCore.Instance?.Dirty(source, patch); - });*/ + }); /*Task.Run(() => { diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs index 3c63ac3a..22d7aa1e 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs @@ -7,7 +7,7 @@ using System.Text.Json; using System.Threading.Tasks; using GeneralUpdate.ClientCore.Strategys; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Download; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Bootstrap; diff --git a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs index 6e48c04b..548bac28 100644 --- a/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs +++ b/src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs @@ -8,7 +8,7 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Event; using GeneralUpdate.Common.Shared.Object; diff --git a/src/c#/GeneralUpdate.ClientCore/Pipeline/PatchMiddleware.cs b/src/c#/GeneralUpdate.ClientCore/Pipeline/PatchMiddleware.cs index c0ea6587..8c9c2ecf 100644 --- a/src/c#/GeneralUpdate.ClientCore/Pipeline/PatchMiddleware.cs +++ b/src/c#/GeneralUpdate.ClientCore/Pipeline/PatchMiddleware.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Internal.Pipeline; using GeneralUpdate.Differential; diff --git a/src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs b/src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs index ef92acbc..0edc1c91 100644 --- a/src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs @@ -3,7 +3,7 @@ using System.IO; using System.Threading.Tasks; using GeneralUpdate.ClientCore.Pipeline; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Event; using GeneralUpdate.Common.Internal.Pipeline; diff --git a/src/c#/GeneralUpdate.Common/Download/DownloadManager.cs b/src/c#/GeneralUpdate.Common/Download/DownloadManager.cs index 849c14e0..a6694103 100644 --- a/src/c#/GeneralUpdate.Common/Download/DownloadManager.cs +++ b/src/c#/GeneralUpdate.Common/Download/DownloadManager.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using System.Collections.Immutable; using System.Diagnostics; -using System.Diagnostics.Contracts; using System.Linq; namespace GeneralUpdate.Common.Download diff --git a/src/c#/GeneralUpdate.Common/File/FileNode.cs b/src/c#/GeneralUpdate.Common/File/FileNode.cs deleted file mode 100644 index 04e1da83..00000000 --- a/src/c#/GeneralUpdate.Common/File/FileNode.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; - -namespace GeneralUpdate.Common; - - public class FileNode - { - #region Public Properties - - public long Id { get; set; } - - public string Name { get; set; } - - public string FullName { get; set; } - - public string Path { get; set; } - - public string Hash { get; set; } - - public FileNode Left { get; set; } - - public FileNode Right { get; set; } - - public int LeftType { get; set; } - - public int RightType { get; set; } - - public string RelativePath { get; set; } - - #endregion Public Properties - - #region Constructors - - public FileNode() - { } - - public FileNode(int id) - { - Id = id; - } - - #endregion Constructors - - #region Public Methods - - public void Add(FileNode node) - { - if (node == null) return; - - if (node.Id < Id) - { - if (Left == null) - { - Left = node; - } - else - { - Left.Add(node); - } - } - else - { - if (Right == null) - { - Right = node; - } - else - { - Right.Add(node); - } - } - } - - public void InfixOrder() - { - if (Left != null) - { - Left.InfixOrder(); - } - if (Right != null) - { - Right.InfixOrder(); - } - } - - public FileNode Search(long id) - { - if (id == Id) - { - return this; - } - else if (id < Id) - { - if (Left == null) return null; - return Left.Search(id); - } - else - { - if (Right == null) return null; - return Right.Search(id); - } - } - - /// - /// Find the parent node of the node that you want to delete. - /// - /// - /// - public FileNode SearchParent(long id) - { - if (Left != null && Left.Id == id || Right != null && Right.Id == id) - { - return this; - } - else - { - if (id < Id && Left != null) - { - return Left.SearchParent(id); - } - else if (id >= Id && Right != null) - { - return Right.SearchParent(id); - } - else - { - return null; - } - } - } - - /// - /// Compare tree nodes equally by Hash and file names. - /// - /// - /// - public override bool Equals(object obj) - { - if (obj == null) return false; - var tempNode = obj as FileNode; - if (tempNode == null) throw new ArgumentException(nameof(tempNode)); - return string.Equals(Hash, tempNode.Hash, StringComparison.OrdinalIgnoreCase) && string.Equals(Name, tempNode.Name, StringComparison.OrdinalIgnoreCase); - } - - public override int GetHashCode() => base.GetHashCode(); - - #endregion Public Methods - } diff --git a/src/c#/GeneralUpdate.Common/File/BlackListManager.cs b/src/c#/GeneralUpdate.Common/FileBasic/BlackListManager.cs similarity index 98% rename from src/c#/GeneralUpdate.Common/File/BlackListManager.cs rename to src/c#/GeneralUpdate.Common/FileBasic/BlackListManager.cs index 1ca7db3c..aea2517d 100644 --- a/src/c#/GeneralUpdate.Common/File/BlackListManager.cs +++ b/src/c#/GeneralUpdate.Common/FileBasic/BlackListManager.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.IO; -namespace GeneralUpdate.Common; +namespace GeneralUpdate.Common.FileBasic; public class BlackListManager { diff --git a/src/c#/GeneralUpdate.Common/File/ComparisonResult.cs b/src/c#/GeneralUpdate.Common/FileBasic/ComparisonResult.cs similarity index 96% rename from src/c#/GeneralUpdate.Common/File/ComparisonResult.cs rename to src/c#/GeneralUpdate.Common/FileBasic/ComparisonResult.cs index 089d54ed..41dbf234 100644 --- a/src/c#/GeneralUpdate.Common/File/ComparisonResult.cs +++ b/src/c#/GeneralUpdate.Common/FileBasic/ComparisonResult.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace GeneralUpdate.Common; +namespace GeneralUpdate.Common.FileBasic; /// /// Result of a comparison between two directories. diff --git a/src/c#/GeneralUpdate.Common/FileBasic/FileNode.cs b/src/c#/GeneralUpdate.Common/FileBasic/FileNode.cs new file mode 100644 index 00000000..90b3831a --- /dev/null +++ b/src/c#/GeneralUpdate.Common/FileBasic/FileNode.cs @@ -0,0 +1,150 @@ +using System; + +namespace GeneralUpdate.Common.FileBasic; + +public class FileNode +{ + #region Public Properties + + public long Id { get; set; } + + public string Name { get; set; } + + public string FullName { get; set; } + + public string Path { get; set; } + + public string Hash { get; set; } + + public FileNode Left { get; set; } + + public FileNode Right { get; set; } + + public int LeftType { get; set; } + + public int RightType { get; set; } + + public string RelativePath { get; set; } + + #endregion Public Properties + + #region Constructors + + public FileNode() + { + } + + public FileNode(int id) + { + Id = id; + } + + #endregion Constructors + + #region Public Methods + + public void Add(FileNode node) + { + if (node == null) return; + + if (node.Id < Id) + { + if (Left == null) + { + Left = node; + } + else + { + Left.Add(node); + } + } + else + { + if (Right == null) + { + Right = node; + } + else + { + Right.Add(node); + } + } + } + + public void InfixOrder() + { + if (Left != null) + { + Left.InfixOrder(); + } + + if (Right != null) + { + Right.InfixOrder(); + } + } + + public FileNode Search(long id) + { + if (id == Id) + { + return this; + } + else if (id < Id) + { + if (Left == null) return null; + return Left.Search(id); + } + else + { + if (Right == null) return null; + return Right.Search(id); + } + } + + /// + /// Find the parent node of the node that you want to delete. + /// + /// + /// + public FileNode SearchParent(long id) + { + if (Left != null && Left.Id == id || Right != null && Right.Id == id) + { + return this; + } + else + { + if (id < Id && Left != null) + { + return Left.SearchParent(id); + } + else if (id >= Id && Right != null) + { + return Right.SearchParent(id); + } + else + { + return null; + } + } + } + + /// + /// Compare tree nodes equally by Hash and file names. + /// + /// + /// + public override bool Equals(object obj) + { + if (obj == null) return false; + var tempNode = obj as FileNode; + if (tempNode == null) throw new ArgumentException(nameof(tempNode)); + return string.Equals(Hash, tempNode.Hash, StringComparison.OrdinalIgnoreCase) && + string.Equals(Name, tempNode.Name, StringComparison.OrdinalIgnoreCase); + } + + public override int GetHashCode() => base.GetHashCode(); + + #endregion Public Methods +} diff --git a/src/c#/GeneralUpdate.Common/File/FileTree.cs b/src/c#/GeneralUpdate.Common/FileBasic/FileTree.cs similarity index 99% rename from src/c#/GeneralUpdate.Common/File/FileTree.cs rename to src/c#/GeneralUpdate.Common/FileBasic/FileTree.cs index c05289c6..085013c7 100644 --- a/src/c#/GeneralUpdate.Common/File/FileTree.cs +++ b/src/c#/GeneralUpdate.Common/FileBasic/FileTree.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; -namespace GeneralUpdate.Common; +namespace GeneralUpdate.Common.FileBasic; /// /// Simple file binary tree. diff --git a/src/c#/GeneralUpdate.Common/File/GeneralFileManager.cs b/src/c#/GeneralUpdate.Common/FileBasic/GeneralFileManager.cs similarity index 99% rename from src/c#/GeneralUpdate.Common/File/GeneralFileManager.cs rename to src/c#/GeneralUpdate.Common/FileBasic/GeneralFileManager.cs index 4a323694..52da377b 100644 --- a/src/c#/GeneralUpdate.Common/File/GeneralFileManager.cs +++ b/src/c#/GeneralUpdate.Common/FileBasic/GeneralFileManager.cs @@ -6,7 +6,7 @@ using System.Threading; using GeneralUpdate.Common.HashAlgorithms; -namespace GeneralUpdate.Common +namespace GeneralUpdate.Common.FileBasic { public sealed class GeneralFileManager { diff --git a/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs b/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs index 67fa36c2..96400bc3 100644 --- a/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs +++ b/src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs @@ -113,4 +113,6 @@ public class GlobalConfigInfo public int Platform { get; set; } public string ProductId { get; set; } + + public Dictionary FieldMappings { get; set; } } \ No newline at end of file diff --git a/src/c#/GeneralUpdate.Core/Driver/DriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/DriverCommand.cs index d5c57c3b..00cb4500 100644 --- a/src/c#/GeneralUpdate.Core/Driver/DriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/DriverCommand.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; namespace GeneralUpdate.Core.Driver { diff --git a/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs b/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs index e30d9b6f..064735b0 100644 --- a/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs +++ b/src/c#/GeneralUpdate.Core/Driver/RestoreDriverCommand.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Text; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; namespace GeneralUpdate.Core.Driver { diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs index 5437a2fb..33269db9 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/GeneralUpdateBootstrap.cs @@ -1,11 +1,12 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Download; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Bootstrap; @@ -73,6 +74,12 @@ public override async Task LaunchAsync() #region public method + public GeneralUpdateBootstrap SetFieldMappings(Dictionary fieldMappings) + { + _configInfo.FieldMappings = fieldMappings; + return this; + } + public GeneralUpdateBootstrap AddListenerMultiAllDownloadCompleted( Action callbackAction) => AddListener(callbackAction); diff --git a/src/c#/GeneralUpdate.Core/Pipeline/DriverMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/DriverMiddleware.cs index 60a0dd47..0c17535e 100644 --- a/src/c#/GeneralUpdate.Core/Pipeline/DriverMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipeline/DriverMiddleware.cs @@ -30,13 +30,20 @@ public Task InvokeAsync(PipelineContext context) if(string.IsNullOrWhiteSpace(patchPath)) return; + var fieldMappings = context.Get>("FieldMappings"); + if(fieldMappings == null || fieldMappings.Count == 0) + return; + var information = new DriverInformation.Builder() .SetDriverFileExtension(FileExtension) .SetOutPutDirectory(outPutPath) + .SetDriverDirectory(patchPath) + .SetFieldMappings(fieldMappings) .Build(); var processor = new DriverProcessor(); processor.AddCommand(new BackupDriverCommand(information)); + processor.AddCommand(new DeleteDriverCommand(information)); processor.AddCommand(new InstallDriverCommand(information)); processor.ProcessCommands(); }); diff --git a/src/c#/GeneralUpdate.Core/Pipeline/PatchMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/PatchMiddleware.cs index 6f9807b1..fcf1b8c7 100644 --- a/src/c#/GeneralUpdate.Core/Pipeline/PatchMiddleware.cs +++ b/src/c#/GeneralUpdate.Core/Pipeline/PatchMiddleware.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Internal.Pipeline; using GeneralUpdate.Differential; diff --git a/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs index 9094cc77..83c0ae02 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs @@ -6,7 +6,7 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Download; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Event; diff --git a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs index 0ad98412..279e3819 100644 --- a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.IO; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.Internal; using GeneralUpdate.Common.Internal.Event; using GeneralUpdate.Common.Internal.Pipeline; @@ -52,6 +52,7 @@ public override void Execute() context.Add("BlackFileFormats", BlackListManager.Instance.BlackFileFormats); //Driver middleware context.Add("DriverOutPut", GeneralFileManager.GetTempDirectory("DriverOutPut")); + context.Add("FieldMappings", _configinfo.FieldMappings); var pipelineBuilder = new PipelineBuilder(context) .UseMiddleware() diff --git a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs index 420046c3..a25f84e2 100644 --- a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs +++ b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs @@ -4,7 +4,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using GeneralUpdate.Common; +using GeneralUpdate.Common.FileBasic; using GeneralUpdate.Common.HashAlgorithms; namespace GeneralUpdate.Differential diff --git a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj index b48d2f58..ae772653 100644 --- a/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj +++ b/src/c#/GeneralUpdate.Differential/GeneralUpdate.Differential.csproj @@ -4,7 +4,6 @@ netstandard2.0 GeneralUpdate.ico GeneralUpdate128.png - False https://github.com/JusterZhu/GeneralUpdate The binary differential update function is provided, but the configuration file update function is reserved. juster.zhu @@ -17,7 +16,6 @@ - diff --git a/src/c#/GeneralUpdate.Upgrad/Program.cs b/src/c#/GeneralUpdate.Upgrad/Program.cs index 06ba8555..947fdca7 100644 --- a/src/c#/GeneralUpdate.Upgrad/Program.cs +++ b/src/c#/GeneralUpdate.Upgrad/Program.cs @@ -1,4 +1,10 @@ -using GeneralUpdate.Core.Driver; +using System.Text; +using GeneralUpdate.Common.Download; +using GeneralUpdate.Common.Internal; +using GeneralUpdate.Common.Internal.Bootstrap; +using GeneralUpdate.Common.Shared.Object; +using GeneralUpdate.Core; +using GeneralUpdate.Core.Driver; namespace GeneralUpdate.Upgrad { @@ -9,7 +15,8 @@ private static void Main(string[] args) var fileExtension = ".inf"; var outPutPath = @"D:\drivers\"; var driversPath = @"D:\driverslocal\"; - + + //中文操作系统的驱动包字段映射表,用于解析所有驱动包的信息的字符串 var fieldMappingsCN = new Dictionary { { "PublishedName", "发布名称" }, @@ -20,7 +27,8 @@ private static void Main(string[] args) { "Version", "驱动程序版本" }, { "Signer", "签名者姓名" } }; - + + //英文操作系统的驱动包字段映射表,用于解析所有驱动包的信息的字符串 var fieldMappingsEN = new Dictionary { { "PublishedName", "Driver" }, @@ -29,8 +37,8 @@ private static void Main(string[] args) { "ClassName", "ClassName" }, { "Version", "Version" } }; - - var information = new DriverInformation.Builder() + + /*var information = new DriverInformation.Builder() .SetDriverFileExtension(fileExtension) .SetOutPutDirectory(outPutPath) .SetDriverDirectory(driversPath) @@ -41,9 +49,54 @@ private static void Main(string[] args) processor.AddCommand(new BackupDriverCommand(information)); processor.AddCommand(new DeleteDriverCommand(information)); processor.AddCommand(new InstallDriverCommand(information)); - processor.ProcessCommands(); + processor.ProcessCommands();*/ + + Task.Run(() => + { + _ = new GeneralUpdateBootstrap() //单个或多个更新包下载通知事件 + .AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged) + //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件 + .AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics) + //单个或多个更新包下载完成 + .AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted) + //完成所有的下载任务通知 + .AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted) + //下载过程出现的异常通知 + .AddListenerMultiDownloadError(OnMultiDownloadError) + //整个更新过程出现的任何问题都会通过这个事件通知 + .AddListenerException(OnException) + //设置字段映射表,用于解析所有驱动包的信息的字符串 + //.SetFieldMappings(fieldMappingsCN) + //是否开启驱动更新 + //.Option(UpdateOption.Drive, true) + .LaunchAsync(); + }); Console.Read(); } + + private static void OnMultiDownloadError(object arg1, MultiDownloadErrorEventArgs arg2) + { + } + + private static void OnMultiAllDownloadCompleted(object arg1, MultiAllDownloadCompletedEventArgs arg2) + { + } + + private static void OnMultiDownloadCompleted(object arg1, MultiDownloadCompletedEventArgs arg2) + { + } + + private static void OnMultiDownloadStatistics(object arg1, MultiDownloadStatisticsEventArgs arg2) + { + } + + private static void OnMultiDownloadProgressChanged(object arg1, MultiDownloadProgressChangedEventArgs arg2) + { + } + + private static void OnException(object arg1, ExceptionEventArgs arg2) + { + } } } \ No newline at end of file