public static bool TryParseActionableResponse(ServiceResponse serviceResponse, out string sourceCommand, out bool responseSuccess)
{
bool parseSucceeded = false;
sourceCommand = null;
responseSuccess = false;
try
{
string response = serviceResponse.Type;
// Attempt to parse response message
if (!string.IsNullOrWhiteSpace(response))
{
// Response types are formatted as "Command:Success" or "Command:Failure"
string[] parts = response.Split(':');
if (parts.Length > 1)
{
sourceCommand = parts[0].Trim().ToTitleCase();
responseSuccess = (string.Compare(parts[1].Trim(), "Success", StringComparison.OrdinalIgnoreCase) == 0);
parseSucceeded = true;
}
}
}
catch
{
parseSucceeded = false;
}
return parseSucceeded;
}