Updater.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Generic;
  2. using Microsoft;
  3. using Update.Core.Entities;
  4. using Update.Core.Events;
  5. using Update.Net;
  6. namespace Update.Core
  7. {
  8. /// <summary>
  9. /// 更新器 by 许崇雷
  10. /// </summary>
  11. public partial class Updater : Disposable, IUpdater
  12. {
  13. private static readonly char[] PERIOD = { '.', '。' }; //句号
  14. public static readonly string PACKAGES = "MBI_Package"; //服务端更新包列表文件
  15. private static readonly string PACKAGE_DELETE = "delete.txt"; //更新包要删除列表文件
  16. private UpdateClient m_Client; //客户端
  17. private IEnumerator<IPackage> m_Avaliables; //更新枚举器
  18. /// <summary>
  19. /// 构造函数
  20. /// </summary>
  21. public Updater()
  22. {
  23. this.m_Client = new UpdateClient { Encoding = System.Text.Encoding.UTF8 };
  24. this.m_Client.KillProgressChanged += (sender, e) => this.OnProgress(new ProgressEventArgs(e.ProgressPercentage));
  25. this.m_Client.KillProcessCompleted += (sender, e) => this.ClientKillCompleted(e);
  26. this.m_Client.DownloadProgressChanged += (sender, e) => this.OnProgress(new ProgressEventArgs(e.ProgressPercentage));
  27. this.m_Client.DownloadStringCompleted += (sender, e) => this.ClientCheckCompleted(e);
  28. this.m_Client.DownloadDataCompleted += (sender, e) => this.ClientDownloadCompleted(e);
  29. this.m_Client.DecompressProgressChanged += (sender, e) => this.OnProgress(new ProgressEventArgs(e.ProgressPercentage));
  30. this.m_Client.DecompressDataCompleted += (sender, e) => this.ClientDecompressCompleted(e);
  31. }
  32. }
  33. }