DebugCommandResult.cs 851 B

1234567891011121314
  1. using Newtonsoft.Json;
  2. namespace IvfTl.ControlHost.Debug
  3. {
  4. /// <summary>命令/借用统一返回体。code 见 spec §4。</summary>
  5. public class DebugCommandResult
  6. {
  7. [JsonProperty("ok")] public bool Ok { get; set; }
  8. [JsonProperty("result", NullValueHandling = NullValueHandling.Ignore)] public object Result { get; set; }
  9. [JsonProperty("error", NullValueHandling = NullValueHandling.Ignore)] public string Error { get; set; }
  10. [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] public string Code { get; set; }
  11. public static DebugCommandResult Okay(object result = null) => new DebugCommandResult { Ok = true, Result = result };
  12. public static DebugCommandResult Fail(string code, string error) => new DebugCommandResult { Ok = false, Code = code, Error = error };
  13. }
  14. }