Skip to content

Commit 8cad12d

Browse files
committed
ActionInterceptor嵌套到HttpApi静态类
1 parent f9cdcc5 commit 8cad12d

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

WebApiClientCore/BuildInProxies/ActionInterceptor.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

WebApiClientCore/HttpApi.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,37 @@ public static THttpApi Create<THttpApi>(IActionInterceptor actionInterceptor)
5151
{
5252
return HttpApiProxyBuilder<THttpApi>.Build(actionInterceptor);
5353
}
54+
55+
56+
/// <summary>
57+
/// 表示httpApi方法调用的拦截器
58+
/// </summary>
59+
private class ActionInterceptor : IActionInterceptor
60+
{
61+
/// <summary>
62+
/// 服务上下文
63+
/// </summary>
64+
private readonly HttpClientContext context;
65+
66+
/// <summary>
67+
/// httpApi方法调用的拦截器
68+
/// </summary>
69+
/// <param name="context">服务上下文</param>
70+
public ActionInterceptor(HttpClientContext context)
71+
{
72+
this.context = context;
73+
}
74+
75+
/// <summary>
76+
/// 拦截方法的调用
77+
/// </summary>
78+
/// <param name="actionInvoker">action执行器</param>
79+
/// <param name="arguments">方法的参数集合</param>
80+
/// <returns></returns>
81+
public object Intercept(IActionInvoker actionInvoker, object?[] arguments)
82+
{
83+
return actionInvoker.Invoke(this.context, arguments);
84+
}
85+
}
5486
}
5587
}

0 commit comments

Comments
 (0)