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.

86 lines
2.1 KiB

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