private void InternalInterceptSynchronous(IInvocation invocation, OpsLogAttribute attribute) { var methodInfo = invocation.Method ?? invocation.MethodInvocationTarget; var log = CreateOpsLog(methodInfo.DeclaringType.FullName, methodInfo.Name, attribute.LogName, invocation.Arguments, _userContext); try { invocation.Proceed(); log.Succeed = "true"; } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { WriteOpsLog(log); } }
private async Task <TResult> InternalInterceptAsynchronous <TResult>(IInvocation invocation, OpsLogAttribute attribute) { TResult result; var methodInfo = invocation.Method ?? invocation.MethodInvocationTarget; var log = CreateOpsLog(methodInfo.DeclaringType.FullName, methodInfo.Name, attribute.LogName, invocation.Arguments, _userContext); try { invocation.Proceed(); var task = (Task <TResult>)invocation.ReturnValue; result = await task; log.Succeed = "true"; } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { WriteOpsLog(log); } return(result); }