예제 #1
0
        public CellOpExecutionCompletedEvent <TResult> DeepCloneWithExecutionResult(TResult executionResult)
        {
            var result = new CellOpExecutionCompletedEvent <TResult>(
                this.TimestampUtc.DeepClone(),
                this.Details?.DeepClone(),
                executionResult);

            return(result);
        }
예제 #2
0
        /// <inheritdoc />
        public bool Equals(CellOpExecutionCompletedEvent <TResult> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            var result = this.TimestampUtc.IsEqualTo(other.TimestampUtc) &&
                         this.Details.IsEqualTo(other.Details, StringComparer.Ordinal) &&
                         this.ExecutionResult.IsEqualTo(other.ExecutionResult);

            return(result);
        }
예제 #3
0
        private async Task ExecuteOperationCellIfNecessaryAsync(
            IOperationOutputCell <TValue> cell)
        {
            // NOTE: THIS CODE IS A NEAR DUPLICATE OF THE SYNC METHOD ABOVE; NO GOOD WAY TO D.R.Y. IT OUT
            if (cell.GetCellOpExecutionStatus() == CellOpExecutionStatus.NotExecuted)
            {
                CellOpExecutionEventBase operationExecutionEvent;

                try
                {
                    var operationResult = await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <TValue>(cell.Operation);

                    operationExecutionEvent = new CellOpExecutionCompletedEvent <TValue>(this.timestampUtc, null, operationResult);
                }
                catch (OpExecutionAbortedExceptionBase ex)
                {
                    operationExecutionEvent = new CellOpExecutionAbortedEvent(this.timestampUtc, ex.ToString());
                }
                catch (OpExecutionDeemedNotApplicableExceptionBase ex)
                {
                    operationExecutionEvent = new CellOpExecutionDeemedNotApplicableEvent(this.timestampUtc, ex.ToString());
                }
                catch (Exception ex)
                {
                    // The "proper" exception for a protocol to throw is an OpExecutionFailedExceptionBase.
                    // Protocol authors might not comply.
                    operationExecutionEvent = new CellOpExecutionFailedEvent(this.timestampUtc, ex.ToString());
                }

                cell.Record(operationExecutionEvent);
            }
            else if (cell.OperationExecutionEvents.Last().TimestampUtc != this.timestampUtc)
            {
                throw new InvalidOperationException("Something went wrong.  The operation was executed, but the recorded timestamp doesn't match this timestamp.");
            }
        }