ToolState.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace Edgegap
  2. {
  3. public enum ToolState
  4. {
  5. Disconnected,
  6. Connecting,
  7. Connected, // Waiting for a deployment
  8. Building,
  9. Pushing,
  10. ProcessingDeployment,
  11. DeploymentRunning,
  12. }
  13. public static class PluginStateExtensions
  14. {
  15. public static bool CanConnect(this ToolState currentState)
  16. {
  17. return currentState == ToolState.Disconnected;
  18. }
  19. public static bool CanDisconnect(this ToolState currentState)
  20. {
  21. return currentState == ToolState.Connected;
  22. }
  23. public static bool CanStartDeployment(this ToolState currentState)
  24. {
  25. return currentState == ToolState.Connected;
  26. }
  27. public static bool CanStopDeployment(this ToolState currentState)
  28. {
  29. return currentState == ToolState.DeploymentRunning;
  30. }
  31. public static bool CanEditConnectionInfo(this ToolState currentState)
  32. {
  33. return currentState.CanConnect();
  34. }
  35. public static bool HasActiveDeployment(this ToolState currentState)
  36. {
  37. return currentState == ToolState.ProcessingDeployment || currentState == ToolState.DeploymentRunning;
  38. }
  39. }
  40. }