-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathIAsyncMethodInterceptor.cs
30 lines (29 loc) · 1.69 KB
/
IAsyncMethodInterceptor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Reflection;
using System.Threading.Tasks;
namespace Someta
{
/// <summary>
/// Have your extension point implement this interface to be able to intercept *async* method
/// invocations. By using this interface, you can use async/await semantics within your
/// interceptor. Note: this does NOT apply to *properties* unless this interceptor is applied
/// to the actual accessors (get; set;). You can call the original implementation of the method
/// via the provided setter delegate. NOTE: If your extension *also* implements IMethodInterceptor
/// then that interface's Invoke method will not be called for methods that return Task. (As it
/// will be handled by this interface)
/// </summary>
public interface IAsyncMethodInterceptor : IExtensionPoint
{
/// <summary>
/// Called each time the method this interceptor is attached to is invoked.
/// </summary>
/// <param name="methodInfo">The MethodInfo representing the method this extension was applied to.</param>
/// <param name="instance">The instance on which the method was invoked (or null for static methods).</param>
/// <param name="arguments">The arguments passed to the method.</param>
/// <param name="invoker">A delegate you can call to invoke the original method implementation.</param>
/// <returns>The result of the method that should be returned to the caller.</returns>
#region AsyncMethodInterceptor
Task<object> InvokeAsync(MethodInfo methodInfo, object instance, Type[] typeArguments, object[] arguments, Func<object[], Task<object>> invoker);
#endregion
}
}