WxJsonResult.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. /*----------------------------------------------------------------
  15. Copyright (C) 2019 Senparc
  16. 文件名:WxJsonResult.cs
  17. 文件功能描述:同于公众号的JSON返回结果基类(用于菜单接口等)
  18. 创建标识:Senparc - 20150211
  19. 修改标识:Senparc - 20150303
  20. 修改描述:整理接口
  21. 修改标识:Senparc - 20150303
  22. 修改描述:添加QyJsonResult(企业号JSON返回结果)
  23. 修改标识:Senparc - 20150706
  24. 修改描述:调整位置,去除MP下的WxJsonResult
  25. 修改标识:Senparc - 20161108
  26. 修改描述:重写ToString()方法,快捷输出结果
  27. 修改标识:Senparc - 20170702
  28. 修改描述:将 IWxJsonResult 定义从 IJsonResult.cs 文件移入
  29. 修改标识:Senparc - 20170702
  30. 修改描述:v4.13.0 添加 ErrorCodeValue 属性。使用 BaseJsonResult 基类。
  31. ----------------------------------------------------------------*/
  32. using System;
  33. namespace Senparc.Weixin.Entities
  34. {
  35. /// <summary>
  36. /// 包含 errorcode 的 Json 返回结果接口
  37. /// </summary>
  38. public interface IWxJsonResult : IJsonResult
  39. {
  40. /// <summary>
  41. /// 返回结果代码
  42. /// </summary>
  43. ReturnCode errcode { get; set; }
  44. }
  45. /// <summary>
  46. /// 公众号 JSON 返回结果(用于菜单接口等)
  47. /// </summary>
  48. [Serializable]
  49. public class WxJsonResult : BaseJsonResult
  50. {
  51. //会造成循环引用
  52. //public WxJsonResult BaseResult
  53. //{
  54. // get { return this; }
  55. //}
  56. public ReturnCode errcode { get; set; }
  57. /// <summary>
  58. /// 返回消息代码数字(同errcode枚举值)
  59. /// </summary>
  60. public override int ErrorCodeValue { get { return (int)errcode; } }
  61. public override string ToString()
  62. {
  63. return string.Format("WxJsonResult:{{errcode:'{0}',errcode_name:'{1}',errmsg:'{2}'}}",
  64. (int)errcode, errcode.ToString(), errmsg);
  65. }
  66. //public ReturnCode ReturnCode
  67. //{
  68. // get
  69. // {
  70. // try
  71. // {
  72. // return (ReturnCode) errorcode;
  73. // }
  74. // catch
  75. // {
  76. // return ReturnCode.系统繁忙;//如果有“其他错误”的话可以指向其他错误
  77. // }
  78. // }
  79. //}
  80. //public void SerializingCallback()
  81. //{
  82. //}
  83. //public void SrializedCallback(string json)
  84. //{
  85. // throw new NotImplementedException();
  86. //}
  87. //public void DeserializingCallback(string json)
  88. //{
  89. // throw new NotImplementedException();
  90. //}
  91. //public void DeserializedCallback(string json)
  92. //{
  93. // throw new NotImplementedException();
  94. //}
  95. }
  96. }