using Apewer.Models; using System; using System.IO; using System.Net; namespace Apewer.Web { /// [Serializable] public sealed class ApiResponse { #region internal private ApiModel _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 StringPairs Headers { get; set; } = new StringPairs(); /// Cookies。 public CookieCollection Cookies { get; set; } = new CookieCollection(); /// 获取或设置输出模型。 public ApiModel Model { get { return _model; } set { var old = _model; _model = value; RuntimeUtility.Dispose(old); } } /// 当响应 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 } }