You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.1 KiB

8 months ago
3 years ago
8 months ago
4 years ago
8 months ago
4 years ago
3 years ago
2 years ago
4 years ago
4 years ago
4 years ago
8 months ago
4 years ago
3 years ago
4 years ago
8 months ago
4 years ago
8 months ago
4 years ago
4 years ago
4 years ago
2 years ago
  1. using Apewer.Models;
  2. using Apewer.Network;
  3. using System;
  4. using System.IO;
  5. using System.Net;
  6. namespace Apewer.Web
  7. {
  8. /// <summary></summary>
  9. [Serializable]
  10. public sealed class ApiResponse
  11. {
  12. /// <summary>自定义标签。</summary>
  13. public object Tag { get; set; }
  14. #region internal
  15. private object _model = null;
  16. private Json _data = Json.NewObject();
  17. internal bool StopReturn = false;
  18. /// <summary>API 的执行时间。</summary>
  19. public string Duration { get; set; }
  20. /// <summary>Application。</summary>
  21. public string Application { get; set; }
  22. /// <summary>Function。</summary>
  23. public string Function { get; set; }
  24. /// <summary>Random。</summary>
  25. public string Random { get; set; }
  26. #endregion
  27. #region user
  28. /// <summary>头。</summary>
  29. public HttpHeaders Headers { get; set; } = new HttpHeaders();
  30. /// <summary>Cookies。</summary>
  31. public CookieCollection Cookies { get; set; } = new CookieCollection();
  32. /// <summary>获取或设置输出模型。</summary>
  33. public object Model
  34. {
  35. get { return _model; }
  36. set
  37. {
  38. RuntimeUtility.Dispose(_model);
  39. _model = value;
  40. }
  41. }
  42. /// <summary>当响应 Json 时,强制缩进排版。</summary>
  43. public bool Indented { get; set; }
  44. /// <summary>状态。</summary>
  45. public string Status { get; set; }
  46. /// <summary>消息。</summary>
  47. public string Message { get; set; }
  48. /// <summary>自定义数据。</summary>
  49. public Json Data
  50. {
  51. get { return _data; }
  52. set { _data = value ?? Json.NewObject(); }
  53. }
  54. /// <summary>设置 Data 的属性。</summary>
  55. public string this[string name] { get => Data[name]; set => Data[name] = value; }
  56. #endregion
  57. #region Function
  58. /// <summary>设置输出前的检查。</summary>
  59. public ApiPreOutput PreOutput { get; set; }
  60. #endregion
  61. }
  62. }