/// <summary> /// Builds an operation that throws a <see cref="OpExecutionAbortedException"/>. /// </summary> /// <typeparam name="TResult">The type of result.</typeparam> /// <param name="condition">The condition.</param> /// <param name="statement">The statement to execute if the condition is true.</param> /// <param name="elseStatement">The statement to execute if the condition is false.</param> /// <returns> /// The operation. /// </returns> public static IfThenElseOp <TResult> IfThenElse <TResult>( IReturningOperation <bool> condition, IReturningOperation <TResult> statement, IReturningOperation <TResult> elseStatement) { var result = new IfThenElseOp <TResult>(condition, statement, elseStatement); return(result); }
protected override OperationBase DeepCloneInternal() { var result = new IfThenElseOp <TResult>( this.Condition?.DeepClone(), this.Statement?.DeepClone(), this.ElseStatement?.DeepClone()); return(result); }
public IfThenElseOp <TResult> DeepCloneWithElseStatement(IReturningOperation <TResult> elseStatement) { var result = new IfThenElseOp <TResult>( this.Condition?.DeepClone(), this.Statement?.DeepClone(), elseStatement); return(result); }
public IfThenElseOp <TResult> DeepCloneWithCondition(IReturningOperation <bool> condition) { var result = new IfThenElseOp <TResult>( condition, this.Statement?.DeepClone(), this.ElseStatement?.DeepClone()); return(result); }
/// <inheritdoc /> public bool Equals(IfThenElseOp <TResult> other) { if (ReferenceEquals(this, other)) { return(true); } if (ReferenceEquals(other, null)) { return(false); } var result = this.Condition.IsEqualTo(other.Condition) && this.Statement.IsEqualTo(other.Statement) && this.ElseStatement.IsEqualTo(other.ElseStatement); return(result); }
/// <inheritdoc /> public async Task <TResult> ExecuteAsync( IfThenElseOp <TResult> operation) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } TResult result; // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <bool>(operation.Condition)) { result = await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <TResult>(operation.Statement); } else { result = await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <TResult>(operation.ElseStatement); } return(result); }