|
|
@ -2,7 +2,6 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Reflection; |
|
|
using System.Reflection; |
|
|
using System.Text; |
|
|
|
|
|
|
|
|
|
|
|
namespace Apewer.Web |
|
|
namespace Apewer.Web |
|
|
{ |
|
|
{ |
|
|
@ -19,6 +18,7 @@ namespace Apewer.Web |
|
|
string _path = null; |
|
|
string _path = null; |
|
|
HttpMethod[] _methods = null; |
|
|
HttpMethod[] _methods = null; |
|
|
ApiParameter[] _parameters = null; |
|
|
ApiParameter[] _parameters = null; |
|
|
|
|
|
UnparallelAttribute _unparallel = null; |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -55,6 +55,9 @@ namespace Apewer.Web |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>不可并行。</summary>
|
|
|
|
|
|
public UnparallelAttribute Unparallel { get => _unparallel; } |
|
|
|
|
|
|
|
|
/// <summary>生成 JSON 实例。</summary>
|
|
|
/// <summary>生成 JSON 实例。</summary>
|
|
|
public Json ToJson() => ToJson(null); |
|
|
public Json ToJson() => ToJson(null); |
|
|
|
|
|
|
|
|
@ -109,9 +112,10 @@ namespace Apewer.Web |
|
|
/// <param name="path">URL 路径。</param>
|
|
|
/// <param name="path">URL 路径。</param>
|
|
|
/// <param name="methods">HTTP 方法。</param>
|
|
|
/// <param name="methods">HTTP 方法。</param>
|
|
|
/// <param name="parameters">参数。</param>
|
|
|
/// <param name="parameters">参数。</param>
|
|
|
|
|
|
/// <param name="unparallel">不可并行。</param>
|
|
|
/// <exception cref="ArgumentNullException" />
|
|
|
/// <exception cref="ArgumentNullException" />
|
|
|
/// <exception cref="ArgumentException" />
|
|
|
/// <exception cref="ArgumentException" />
|
|
|
ApiAction(Type type, MethodInfo method, string path, HttpMethod[] methods, ApiParameter[] parameters) |
|
|
|
|
|
|
|
|
ApiAction(Type type, MethodInfo method, string path, HttpMethod[] methods, ApiParameter[] parameters, UnparallelAttribute unparallel) |
|
|
{ |
|
|
{ |
|
|
if (type == null) throw new ArgumentNullException(nameof(type)); |
|
|
if (type == null) throw new ArgumentNullException(nameof(type)); |
|
|
if (method == null) throw new ArgumentNullException(nameof(method)); |
|
|
if (method == null) throw new ArgumentNullException(nameof(method)); |
|
|
@ -128,6 +132,7 @@ namespace Apewer.Web |
|
|
_path = path; |
|
|
_path = path; |
|
|
_methods = methods; |
|
|
_methods = methods; |
|
|
_parameters = parameters; |
|
|
_parameters = parameters; |
|
|
|
|
|
_unparallel = unparallel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>解析控制器类型,获取 API 活动。</summary>
|
|
|
/// <summary>解析控制器类型,获取 API 活动。</summary>
|
|
|
@ -213,7 +218,10 @@ namespace Apewer.Web |
|
|
parameters.Add(parameter); |
|
|
parameters.Add(parameter); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var action = new ApiAction(type, method, path, httpMethods.ToArray(), parameters.ToArray()); |
|
|
|
|
|
|
|
|
// 不可并行
|
|
|
|
|
|
var unparallel = RuntimeUtility.GetAttribute<UnparallelAttribute>(method); |
|
|
|
|
|
|
|
|
|
|
|
var action = new ApiAction(type, method, path, httpMethods.ToArray(), parameters.ToArray(), unparallel); |
|
|
actions.Add(action); |
|
|
actions.Add(action); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|