2023-08-16 03:41:14 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace MSFSPopoutPanelManager.Shared
|
|
|
|
|
{
|
|
|
|
|
public static class WorkflowStepWithMessage
|
|
|
|
|
{
|
|
|
|
|
public static void Execute(string message, Func<bool> function, bool isSubTask = false)
|
|
|
|
|
{
|
|
|
|
|
if (isSubTask)
|
2023-08-17 06:03:17 +00:00
|
|
|
|
message = " - " + message;
|
2023-08-16 03:41:14 +00:00
|
|
|
|
|
|
|
|
|
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
|
|
|
|
StatusMessageWriter.WriteExecutingStatusMessage();
|
|
|
|
|
|
|
|
|
|
var result = function.Invoke();
|
|
|
|
|
|
|
|
|
|
StatusMessageWriter.RemoveLastMessage();
|
|
|
|
|
if (result)
|
|
|
|
|
StatusMessageWriter.WriteOkStatusMessage();
|
|
|
|
|
else
|
|
|
|
|
StatusMessageWriter.WriteFailureStatusMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Execute(string message, Action function, bool isSubTask = false)
|
|
|
|
|
{
|
|
|
|
|
if (isSubTask)
|
2023-08-17 06:03:17 +00:00
|
|
|
|
message = " - " + message;
|
2023-08-16 03:41:14 +00:00
|
|
|
|
|
|
|
|
|
StatusMessageWriter.WriteMessage(message, StatusMessageType.Info);
|
|
|
|
|
StatusMessageWriter.WriteExecutingStatusMessage();
|
|
|
|
|
|
|
|
|
|
function.Invoke();
|
|
|
|
|
|
|
|
|
|
StatusMessageWriter.RemoveLastMessage();
|
|
|
|
|
StatusMessageWriter.WriteOkStatusMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|