public virtual void Intercept(IInvocation invocation) { Method method = new Method(invocation.Method); bool snapShotEnabled = method.HasAttribute(typeof(WorkSnapshotAttribute)); LastServiceCallStatus lastServiceCallStatus = serviceExecution.Invoking(service, invocation.Method); if (lastServiceCallStatus.WasExecuted) { invocation.ReturnValue = lastServiceCallStatus.ReturnValue; } else { if (snapShotEnabled) { serviceExecution.TakeSnapshot(); } ReflectedObject reflectedServiceObject = new ReflectedObject(service); sessionReport.Begin(invocation.Method.Name); try { invocation.ReturnValue = reflectedServiceObject.Invoke(invocation.Method, invocation.Arguments); serviceExecution.Invoked(invocation.ReturnValue); } catch (Exception e) { sessionReport.Act(); serviceExecution.Error(); throw new WhiteException(string.Format("Error Invoking {0}.{1}", reflectedServiceObject.Class.Name, invocation.Method.Name), e.InnerException); } } }
public virtual void Intercept(IInvocation invocation) { var workSnapshotAttributes = invocation.Method.GetCustomAttributes(typeof(WorkSnapshotAttribute), true); bool snapShotEnabled = workSnapshotAttributes.Any(); LastServiceCallStatus lastServiceCallStatus = serviceExecution.Invoking(service, invocation.Method); if (lastServiceCallStatus.WasExecuted) { invocation.ReturnValue = lastServiceCallStatus.ReturnValue; } else { if (snapShotEnabled) { serviceExecution.TakeSnapshot(); } sessionReport.Begin(invocation.Method.Name); try { invocation.ReturnValue = invocation.Method.Invoke(service, invocation.Arguments); serviceExecution.Invoked(invocation.ReturnValue); } catch (Exception e) { sessionReport.Act(); serviceExecution.Error(); throw new WhiteException(string.Format("Error Invoking {0}.{1}", service.GetType().Name, invocation.Method.Name), e.InnerException); } } }