IBugReporterHandler.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using SRDebugger.Services;
  4. namespace SRDebugger
  5. {
  6. public class BugReport
  7. {
  8. public List<ConsoleEntry> ConsoleLog;
  9. /// <summary>
  10. /// User-entered email address
  11. /// </summary>
  12. public string Email;
  13. /// <summary>
  14. /// Raw data of the captured screenshot (png)
  15. /// </summary>
  16. public byte[] ScreenshotData;
  17. public Dictionary<string, Dictionary<string, object>> SystemInformation;
  18. public string UserDescription;
  19. }
  20. public sealed class BugReportSubmitResult
  21. {
  22. public static BugReportSubmitResult Success
  23. {
  24. get { return new BugReportSubmitResult(true, null); }
  25. }
  26. public static BugReportSubmitResult Error(string errorMessage)
  27. {
  28. return new BugReportSubmitResult(false, errorMessage);
  29. }
  30. public bool IsSuccessful { get; }
  31. public string ErrorMessage { get; }
  32. private BugReportSubmitResult(bool successful, string error)
  33. {
  34. IsSuccessful = successful;
  35. ErrorMessage = error;
  36. }
  37. }
  38. public interface IBugReporterHandler
  39. {
  40. /// <summary>
  41. /// Returns true if this bug reporter handler is able to be used.
  42. /// If false, the bug reporter tab will be hidden.
  43. /// </summary>
  44. bool IsUsable { get; }
  45. /// <summary>
  46. /// Submit a new bug report to the handler.
  47. /// </summary>
  48. /// <param name="report">The report to be submitted.</param>
  49. /// <param name="onComplete">Action to be invoked when the bug report is completed.</param>
  50. /// <param name="progress">Callback to set the current submit progress.</param>
  51. void Submit(BugReport report, Action<BugReportSubmitResult> onComplete, IProgress<float> progress);
  52. }
  53. }