using Apewer.Models; using Apewer.Network; using System; using System.IO; using System.Net; namespace Apewer.Web { /// [Serializable] public sealed class ApiResponse { /// 自定义标签。 public object Tag { get; set; } #region internal private object _model = null; private Json _data = Json.NewObject(); internal bool StopReturn = false; /// API 的执行时间。 public string Duration { get; set; } /// Application。 public string Application { get; set; } /// Function。 public string Function { get; set; } /// Random。 public string Random { get; set; } #endregion #region user /// 头。 public HttpHeaders Headers { get; set; } = new HttpHeaders(); /// Cookies。 public CookieCollection Cookies { get; set; } = new CookieCollection(); /// 获取或设置输出模型。 public object Model { get { return _model; } set { RuntimeUtility.Dispose(_model); _model = value; } } /// 当响应 Json 时,强制缩进排版。 public bool Indented { get; set; } /// 状态。 public string Status { get; set; } /// 消息。 public string Message { get; set; } /// 自定义数据。 public Json Data { get { return _data; } set { _data = value ?? Json.NewObject(); } } /// 设置 Data 的属性。 public string this[string name] { get => Data[name]; set => Data[name] = value; } #endregion #region Function /// 设置输出前的检查。 public ApiPreOutput PreOutput { get; set; } #endregion } }