DebugCommandResult.cs 1.1 KB

12345678910111213141516
  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. [JsonProperty("cultivating", NullValueHandling = NullValueHandling.Ignore)] public bool Cultivating { get; set; }
  12. [JsonProperty("embryoCount", NullValueHandling = NullValueHandling.Ignore)] public int EmbryoCount { get; set; }
  13. public static DebugCommandResult Okay(object result = null) => new DebugCommandResult { Ok = true, Result = result };
  14. public static DebugCommandResult Fail(string code, string error) => new DebugCommandResult { Ok = false, Code = code, Error = error };
  15. }
  16. }