コード例 #1
0
    protected override async Task InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func <IInvocation, IInvocationProceedInfo, Task> proceed)
    {
        var interceptedMethod   = invocation.MethodInvocationTarget;
        var interceptionContext = new InterceptionContext(interceptedMethod);

        var pipeline = new InterceptPipeline(
            interceptionContext: interceptionContext,
            inner: () => proceed(invocation, proceedInfo)
            );

        var steps = _pipelineStepFactory.GetPipelineStepsFor(interceptedMethod);
        await pipeline.Execute(steps);
    }
コード例 #2
0
    protected override async Task <TResult> InterceptAsync <TResult>(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func <IInvocation, IInvocationProceedInfo, Task <TResult> > proceed)
    {
        var interceptedMethod   = invocation.MethodInvocationTarget;
        var interceptionContext = new InterceptionContext(interceptedMethod);

        TResult?result = default;

        var pipeline = new InterceptPipeline(
            interceptionContext: interceptionContext,
            inner: async() =>
        {
            result = await proceed(invocation, proceedInfo);
        });

        var steps = _pipelineStepFactory.GetPipelineStepsFor(interceptedMethod);
        await pipeline.Execute(steps);

        return(result !);
    }