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.

74 lines
2.6 KiB

1 year ago
  1. 
  2. using System;
  3. using TrustedUninstaller.Shared.Actions;
  4. using TrustedUninstaller.Shared.Tasks;
  5. using YamlDotNet.Core.Events;
  6. using YamlDotNet.Serialization;
  7. namespace TrustedUninstaller.Shared.Parser
  8. {
  9. internal class TaskActionResolver : INodeTypeResolver
  10. {
  11. public bool Resolve(NodeEvent? nodeEvent, ref Type currentType)
  12. {
  13. if (!currentType.IsInterface || currentType != typeof(ITaskAction))
  14. {
  15. return false;
  16. }
  17. switch (nodeEvent?.Tag.Value)
  18. {
  19. case "!file:":
  20. currentType = typeof(FileAction);
  21. return true;
  22. case "!service:":
  23. currentType = typeof(ServiceAction);
  24. return true;
  25. case "!user:":
  26. currentType = typeof(UserAction);
  27. return true;
  28. case "!run:":
  29. currentType = typeof(RunAction);
  30. return true;
  31. case "!powerShell:":
  32. currentType = typeof(PowerShellAction);
  33. return true;
  34. case "!shortcut:":
  35. currentType = typeof(ShortcutAction);
  36. return true;
  37. case "!cmd:":
  38. currentType = typeof(CmdAction);
  39. return true;
  40. case "!scheduledTask:":
  41. currentType = typeof(ScheduledTaskAction);
  42. return true;
  43. case "!lineInFile:":
  44. currentType = typeof(LineInFileAction);
  45. return true;
  46. case "!registryKey:":
  47. currentType = typeof(RegistryKeyAction);
  48. return true;
  49. case "!registryValue:":
  50. currentType = typeof(RegistryValueAction);
  51. return true;
  52. case "!appx:":
  53. currentType = typeof(AppxAction);
  54. return true;
  55. case "!systemPackage:":
  56. currentType = typeof(SystemPackageAction);
  57. return true;
  58. case "!taskKill:":
  59. currentType = typeof(TaskKillAction);
  60. return true;
  61. case "!update:":
  62. currentType = typeof(UpdateAction);
  63. return true;
  64. case "!writeStatus:":
  65. currentType = typeof(WriteStatusAction);
  66. return true;
  67. default:
  68. return false;
  69. }
  70. }
  71. }
  72. }