public override async Task InterceptAsync(InterceptContext context, AsyncInterceptDelegate nextAsync) { Console.WriteLine("Async Begin"); await nextAsync(context); Console.WriteLine("Async End"); }
public TestSumServiceProxy(IInterceptDelegateBuilder builder) { sumMethod = typeof(TestSumService).GetMethod("SumAsync", new Type[] { typeof(int), typeof(int) }); sumInterceptor = builder.BuildAsyncInterceptDelegate(sumMethod, async c => { c.Result = await base.SumAsync((int)c.Parameters[0], (int)c.Parameters[1]); }); }
public override async Task InterceptAsync(InterceptContext context, AsyncInterceptDelegate nextAsync) { await nextAsync(context); context.Result = (int)context.Result + 1; }
public AsyncInterceptDelegate BuildAsyncInterceptDelegate(MethodInfo methodInfo, AsyncInterceptDelegate func) { return(asyncCache.GetOrAdd(methodInfo, (m) => { var asyncFunc = func; var builders = boxs.Where(i => i.Verifier(m)) .Select(i => i.Interceptor) .OrderByDescending(i => i.Order) .Select <IInterceptor, Func <AsyncInterceptDelegate, AsyncInterceptDelegate> >(i => next => async c => await i.InterceptAsync(c, next)); foreach (var builder in builders) { asyncFunc = builder(asyncFunc); } return asyncFunc; })); }
public abstract Task InterceptAsync(InterceptContext context, AsyncInterceptDelegate nextAsync);
public override async Task InterceptAsync(InterceptContext context, AsyncInterceptDelegate nextAsync) { throw new NotImplementedException(); }