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.
120 lines
3.1 KiB
120 lines
3.1 KiB
using Apewer;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Apewer.Models
|
|
{
|
|
|
|
[Serializable]
|
|
internal class ApiResponse<T>
|
|
{
|
|
|
|
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; }
|
|
|
|
/// <summary>生成 Json 对象。</summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>生成 Json 字符串,可指定 Json 缩进。</summary>
|
|
public string ToString(bool indented)
|
|
{
|
|
return ToJson().ToString(indented);
|
|
}
|
|
|
|
/// <summary>生成 Json 字符串,默认不缩进。</summary>
|
|
public override string ToString()
|
|
{
|
|
return ToJson().ToString(false);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary></summary>
|
|
[Serializable]
|
|
public class ApiResponse
|
|
{
|
|
|
|
private Json _data = null;
|
|
|
|
/// <summary></summary>
|
|
public string Application { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Beginning { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Ending { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Function { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Message { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Random { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public string Status { get; set; }
|
|
|
|
/// <summary></summary>
|
|
public Json Data { get; set; }
|
|
|
|
/// <summary>生成 Json 对象。</summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>生成 Json 字符串,可指定 Json 缩进。</summary>
|
|
public string ToString(bool indented)
|
|
{
|
|
return ToJson().ToString(indented);
|
|
}
|
|
|
|
/// <summary>生成 Json 字符串,默认不缩进。</summary>
|
|
public override string ToString()
|
|
{
|
|
return ToJson().ToString(false);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|