CLI tool for running Playbooks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.3 KiB

1 year ago
10 months ago
1 year ago
6 months ago
10 months ago
1 year ago
10 months ago
1 year ago
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Text;
  5. using TrustedUninstaller.Shared.Parser;
  6. using YamlDotNet.Serialization;
  7. namespace TrustedUninstaller.Shared.Tasks
  8. {
  9. public class UninstallTask
  10. {
  11. public string Title { get; set; }
  12. #nullable enable
  13. public string? Description { get; set; }
  14. public string[]? SupportedBuilds { get; set; }
  15. public int? MinVersion { get; set; }
  16. public int? MaxVersion { get; set; }
  17. #nullable disable
  18. public UninstallTaskStatus Status { get; set; } = UninstallTaskStatus.ToDo;
  19. public List<ITaskAction> Actions { get; set; } = new List<ITaskAction>();
  20. public int Priority { get; set; } = 1;
  21. public UninstallTaskPrivilege Privilege { get; set; } = UninstallTaskPrivilege.Admin;
  22. [YamlMember(typeof(string), Alias = "option")]
  23. public string Option { get; set; } = null;
  24. [YamlMember(typeof(string[]), Alias = "options")]
  25. public string[] Options { get; set; } = null;
  26. [YamlMember(typeof(string[]), Alias = "builds")]
  27. public string[] Builds { get; set; } = null;
  28. [YamlMember(typeof(string), Alias = "cpuArch")]
  29. public string Arch { get; set; } = null;
  30. public List<string> Features { get; set; } = new List<string>();
  31. public List<string> Tasks
  32. {
  33. set => Features = value;
  34. get => Features;
  35. }
  36. public void Update()
  37. {
  38. /*
  39. var statusList = Actions.Select(entry => entry.GetStatus()).ToList();
  40. if (statusList.Any(entry => entry == UninstallTaskStatus.InProgress))
  41. {
  42. Status = UninstallTaskStatus.InProgress;
  43. }
  44. else if (statusList.All(entry => entry == UninstallTaskStatus.Completed))
  45. {
  46. Status = UninstallTaskStatus.Completed;
  47. }
  48. else
  49. {
  50. Status = UninstallTaskStatus.ToDo;
  51. }
  52. */
  53. }
  54. public override string ToString()
  55. {
  56. var sb = new StringBuilder();
  57. var sw = new StringWriter(sb);
  58. var parser = new ConfigParser();
  59. parser.SerializeItem(sw, this);
  60. return sb.ToString();
  61. }
  62. }
  63. }