namespace ZB.MOM.WW.ScadaBridge.DelmiaNotifier;
///
/// Maps an outcome to the legacy WWNotifier stdout contract: YES + exit 0 on success,
/// NO followed by a reason line + exit -1 on failure. The writer is injected so stdout is the
/// only thing Delmia ever parses (LF-terminated, deterministic across platforms).
///
internal static class Reporter
{
/// Writes the legacy WWNotifier stdout contract for the given outcome.
/// Whether the operation succeeded.
/// The failure reason to write when is false; ignored on success.
/// The writer to which the contract output is written.
/// 0 on success; -1 on failure.
public static int Report(bool ok, string reason, TextWriter stdout)
{
if (ok)
{
stdout.Write("YES\n");
return 0;
}
stdout.Write("NO\n");
stdout.Write(reason);
return -1;
}
}