using Apewer; using System; using System.Collections.Generic; using System.Text; namespace Apewer.Models { [Serializable] internal class ApiResponse { private T _data = default(T); public string Application { get; set; } public string Beginning { get; set; } public string Ending { get; set; } public string Function { get; set; } public string Message { get; set; } public string Random { get; set; } public string Status { get; set; } public T Data { get; set; } /// 生成 Json 对象。 public Json ToJson() { var json = Json.NewObject(); json.SetProperty("beginning", Beginning); json.SetProperty("ending", Ending); json.SetProperty("random", Random); json.SetProperty("application", Application); json.SetProperty("function", Function); json.SetProperty("status", Status); json.SetProperty("message", Message); json.SetProperty("data", Json.Parse(Data)); return json; } /// 生成 Json 字符串,可指定 Json 缩进。 public string ToString(bool indented) { return ToJson().ToString(indented); } /// 生成 Json 字符串,默认不缩进。 public override string ToString() { return ToJson().ToString(false); } } /// [Serializable] public class ApiResponse { private Json _data = null; /// public string Application { get; set; } /// public string Beginning { get; set; } /// public string Ending { get; set; } /// public string Function { get; set; } /// public string Message { get; set; } /// public string Random { get; set; } /// public string Status { get; set; } /// public Json Data { get; set; } /// 生成 Json 对象。 public Json ToJson() { var json = Json.NewObject(); json.SetProperty("beginning", Beginning); json.SetProperty("ending", Ending); json.SetProperty("random", Random); json.SetProperty("application", Application); json.SetProperty("function", Function); json.SetProperty("status", Status); json.SetProperty("message", Message); json.SetProperty("data", Data); return json; } /// 生成 Json 字符串,可指定 Json 缩进。 public string ToString(bool indented) { return ToJson().ToString(indented); } /// 生成 Json 字符串,默认不缩进。 public override string ToString() { return ToJson().ToString(false); } } }