-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleAsyncTracingInterceptor.cs
35 lines (31 loc) · 1.2 KB
/
SampleAsyncTracingInterceptor.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
31
32
33
34
35
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using AsyncInterceptor.AsyncDynamicProxyExtensions;
namespace AsyncInterceptor
{
class SampleAsyncTracingInterceptor : IAsyncInterceptor
{
public void OnBeforeProceed(MethodInfo method, object[] arguments, out object state)
{
Console.WriteLine("Async Intercepting " + method + "(" + string.Join(", ", arguments.Select(x => x.ToString())) + ")");
state = null;
}
public Task OnAfterSuccessfulProceed(MethodInfo method, object[] arguments, object state)
{
Console.WriteLine("Async Intercepted " + method);
return Task.CompletedTask;
}
public void OnExceptionInProceed(MethodInfo method, object[] arguments, object state, Exception ex, out bool rethrow)
{
Console.WriteLine("On noes, Async Intercepted an exception: " + ex.Message);
rethrow = true;
}
public Task OnFinallyAfterProceed(MethodInfo method, object[] arguments, object state)
{
Console.WriteLine("Async Finally after Proceed " + method);
return Task.CompletedTask;
}
}
}