private void PerformAsyncUow(IInvocation invocation, UseCaseAttribute useCaseAttribute) { if (invocation.Method.ReturnType == typeof(Task)) { invocation.ReturnValue = InternalAsyncHelper.AwaitTaskWithUsingActionAndFinally( () => ReasonProvider.Use(useCaseAttribute.Description), () => { invocation.Proceed(); return((Task)invocation.ReturnValue); }, exception => { } ); } else //Task<TResult> { invocation.ReturnValue = InternalAsyncHelper.CallAwaitTaskWithUsingActionAndFinallyAndGetResult( invocation.Method.ReturnType.GenericTypeArguments[0], () => ReasonProvider.Use(useCaseAttribute.Description), () => { invocation.Proceed(); return(invocation.ReturnValue); }, exception => { } ); } }
private void PerformSyncUow(IInvocation invocation, UseCaseAttribute useCaseAttribute) { using (ReasonProvider.Use(useCaseAttribute.Description)) { invocation.Proceed(); } }