DownloadFailureEventArgs.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using GameFramework.Event;
  9. namespace UnityGameFramework.Runtime
  10. {
  11. /// <summary>
  12. /// 下载失败事件。
  13. /// </summary>
  14. public sealed class DownloadFailureEventArgs : GameEventArgs
  15. {
  16. /// <summary>
  17. /// 下载失败事件编号。
  18. /// </summary>
  19. public static readonly int EventId = typeof(DownloadFailureEventArgs).GetHashCode();
  20. /// <summary>
  21. /// 初始化下载失败事件的新实例。
  22. /// </summary>
  23. public DownloadFailureEventArgs()
  24. {
  25. SerialId = 0;
  26. DownloadPath = null;
  27. DownloadUri = null;
  28. ErrorMessage = null;
  29. UserData = null;
  30. }
  31. /// <summary>
  32. /// 获取下载失败事件编号。
  33. /// </summary>
  34. public override int Id
  35. {
  36. get
  37. {
  38. return EventId;
  39. }
  40. }
  41. /// <summary>
  42. /// 获取下载任务的序列编号。
  43. /// </summary>
  44. public int SerialId
  45. {
  46. get;
  47. private set;
  48. }
  49. /// <summary>
  50. /// 获取下载后存放路径。
  51. /// </summary>
  52. public string DownloadPath
  53. {
  54. get;
  55. private set;
  56. }
  57. /// <summary>
  58. /// 获取下载地址。
  59. /// </summary>
  60. public string DownloadUri
  61. {
  62. get;
  63. private set;
  64. }
  65. /// <summary>
  66. /// 获取错误信息。
  67. /// </summary>
  68. public string ErrorMessage
  69. {
  70. get;
  71. private set;
  72. }
  73. /// <summary>
  74. /// 获取用户自定义数据。
  75. /// </summary>
  76. public object UserData
  77. {
  78. get;
  79. private set;
  80. }
  81. /// <summary>
  82. /// 创建下载失败事件。
  83. /// </summary>
  84. /// <param name="e">内部事件。</param>
  85. /// <returns>创建的下载失败事件。</returns>
  86. public static DownloadFailureEventArgs Create(GameFramework.Download.DownloadFailureEventArgs e)
  87. {
  88. DownloadFailureEventArgs downloadFailureEventArgs = ReferencePool.Acquire<DownloadFailureEventArgs>();
  89. downloadFailureEventArgs.SerialId = e.SerialId;
  90. downloadFailureEventArgs.DownloadPath = e.DownloadPath;
  91. downloadFailureEventArgs.DownloadUri = e.DownloadUri;
  92. downloadFailureEventArgs.ErrorMessage = e.ErrorMessage;
  93. downloadFailureEventArgs.UserData = e.UserData;
  94. return downloadFailureEventArgs;
  95. }
  96. /// <summary>
  97. /// 清理下载失败事件。
  98. /// </summary>
  99. public override void Clear()
  100. {
  101. SerialId = 0;
  102. DownloadPath = null;
  103. DownloadUri = null;
  104. ErrorMessage = null;
  105. UserData = null;
  106. }
  107. }
  108. }