UpdaterListener.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace MPQ.Updater
  5. {
  6. public class MPQUpdaterEvent
  7. {
  8. public const int TYPE_COMPLETE = 1;
  9. public const int TYPE_VALIDATING = 2;
  10. public const int TYPE_DOWNLOADING = 3;
  11. public const int TYPE_UNZIP = 4;
  12. public const int TYPE_ERROR = -1;
  13. public const int TYPE_NOT_ENOUGH_SPACE = -2;
  14. public const int TYPE_NA = 0;
  15. public int EventType { get; private set; }
  16. public string Message { get; private set; }
  17. public Exception Cause { get; private set; }
  18. public MPQUpdaterEvent(int type, string message, Exception err=null)
  19. {
  20. this.EventType = type;
  21. this.Message = message;
  22. this.Cause = err;
  23. }
  24. override public string ToString()
  25. {
  26. string ret = "Code=" + EventType;
  27. if (Message != null)
  28. return "\n" + Message;
  29. if (Cause != null)
  30. return "\n" + Cause.Message;
  31. return ret;
  32. }
  33. }
  34. public interface MPQUpdaterListener
  35. {
  36. void onEvent(MPQUpdater updater, MPQUpdaterEvent e);
  37. }
  38. }