CompressArgs.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* ==============================================================================
  2. * 功能描述:CompressArgs
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/2/13 17:51:10
  5. * ==============================================================================*/
  6. /* ==============================================================================
  7. * 功能描述:压缩请求
  8. * 创 建 者:SAGACLOUD
  9. * 创建日期:2017/9/17
  10. * ==============================================================================*/
  11. using System;
  12. namespace PackageUploader.Compress
  13. {
  14. /// <summary>
  15. /// CompressArgs
  16. /// </summary>
  17. public class CompressArgs : EventArgs
  18. {
  19. public CompressArgs(long incrementTransferred, long transferred, long total,Action<string> action)
  20. {
  21. this.IncrementTransferred = incrementTransferred;
  22. this.TransferredBytes = transferred;
  23. this.TotalBytes = total;
  24. m_IncrementChangeAction = action;
  25. }
  26. public long IncrementTransferred {
  27. set
  28. {
  29. TransferredBytes += value;
  30. m_IncrementChangeAction?.Invoke(this.ToString());
  31. } }
  32. public long TransferredBytes { get; set; }
  33. public long TotalBytes { get; }
  34. public override string ToString()
  35. {
  36. return $"CompressCallback - TotalBytes:{TotalBytes/1024/1024}M, CompressedBytes:{TransferredBytes/1024/1024}M,CompressedPercent:{Math.Round(100d* TransferredBytes / TotalBytes, 3)}%";
  37. }
  38. private Action<string> m_IncrementChangeAction;
  39. }
  40. }