public void Execute(OperationHandlers operationHandlers) { var info = new OperationInfo { OperationId = _operationIdFactory.GetNextId() }; operationHandlers.OnBeforeExecute(info); try { operationHandlers.Execute(info); } catch (Exception e) { Logger.LogError(e, "Error executing operation {0}", _operationIdFactory.GetNextId()); operationHandlers.OnError(info, e); } }
public void Execute(OperationInfo <T> operationInfo) { var operationId = _operationIdFactory.GetNextId(); var operationEventArgs = new OperationEventArgs { OperationId = operationId }; operationInfo.OnBeforeExecute(operationEventArgs); try { var result = operationInfo.Execute(operationEventArgs); result.OperationId = operationId; operationInfo.OnAfterExecute(result); } catch (Exception e) { Logger.LogException(e, "Error executing operation {0}", operationId); operationInfo.OnAfterExecute(new T { OperationId = operationId, Error = e }); } }