Skip to content

Commit 22c0d7a

Browse files
committed
v0.2.8
1 parent e1c962e commit 22c0d7a

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

WebApiClient/Defaults/ApiParameterAttributeProvider.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ public bool AddIfNotExists(IApiParameterAttribute attribute)
100100
return true;
101101
}
102102

103-
/// <summary>
104-
/// 转换为数组
105-
/// </summary>
106-
/// <returns></returns>
107-
public IApiParameterAttribute[] ToArray()
108-
{
109-
return this.attribueList.ToArray();
110-
}
111-
112103
/// <summary>
113104
/// 返回迭代器
114105
/// </summary>

WebApiClient/Internal/Attributes/ParameterableAttribute.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,16 @@ class ParameterableAttribute : Attribute, IApiParameterAttribute
1818
/// <param name="parameter">特性关联的参数</param>
1919
/// <returns></returns>
2020
public async Task BeforeRequestAsync(ApiActionContext context, ApiParameterDescriptor parameter)
21-
{
22-
var ables = this.GetApiParameterables(parameter);
23-
foreach (var item in ables)
24-
{
25-
if (item != null)
26-
{
27-
await item.BeforeRequestAsync(context, parameter).ConfigureAwait(false);
28-
}
29-
}
30-
}
31-
32-
/// <summary>
33-
/// 从参数值获取IApiParameterable对象
34-
/// </summary>
35-
/// <param name="parameter"></param>
36-
/// <returns></returns>
37-
private IEnumerable<IApiParameterable> GetApiParameterables(ApiParameterDescriptor parameter)
3821
{
3922
if (parameter.Value is IApiParameterable able)
4023
{
41-
yield return able;
24+
await able.BeforeRequestAsync(context, parameter).ConfigureAwait(false);
4225
}
4326
else if (parameter.Value is IEnumerable<IApiParameterable> array)
4427
{
45-
foreach (var ele in array)
28+
foreach (var item in array)
4629
{
47-
yield return ele;
30+
await item.BeforeRequestAsync(context, parameter).ConfigureAwait(false);
4831
}
4932
}
5033
}

WebApiClient/WebApiClient.csproj

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)