using MxGateway.Contracts.Proto;
namespace MxGateway.Client;
/// Extension methods for MxStatusProxy values.
public static class MxStatusProxyExtensions
{
/// Returns whether the status indicates success (success flag set and category is Ok).
/// The status to check.
public static bool IsSuccess(this MxStatusProxy status)
{
ArgumentNullException.ThrowIfNull(status);
return status.Success != 0
&& status.Category is MxStatusCategory.Ok;
}
/// Returns a formatted summary of the status for diagnostic output.
/// The status to summarize.
public static string ToDiagnosticSummary(this MxStatusProxy status)
{
ArgumentNullException.ThrowIfNull(status);
string diagnosticText = string.IsNullOrWhiteSpace(status.DiagnosticText)
? "no diagnostic text"
: status.DiagnosticText;
return $"{status.Category} by {status.DetectedBy}; detail={status.Detail}; {diagnosticText}";
}
}