/// <inheritdoc /> public async Task <TValue> ExecuteAsync( GetCellValueOp <TValue> operation) { // NOTE: THIS CODE IS A NEAR DUPLICATE OF THE SYNC METHOD ABOVE; NO GOOD WAY TO D.R.Y. IT OUT if (operation == null) { throw new ArgumentNullException(nameof(operation)); } var locatedCell = await this.GetCellAndExecuteOperationIfNecessaryAsync(operation.CellLocator); TValue result; if (locatedCell.Cell.HasCellValue()) { if (!(locatedCell.Cell is IGetCellValue <TValue> getCellValueCell)) { throw new CellNotFoundException(Invariant($"The operation addresses a cell whose type is not an {typeof(IGetCellValue<TValue>).ToStringReadable()}: {locatedCell.Cell.GetType().ToStringReadable()}."), locatedCell.CellLocator); } result = getCellValueCell.GetCellValue(); } else { if (operation.DefaultValue == null) { throw new CellValueMissingException(locatedCell.CellLocator); } result = await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <TValue>(operation.DefaultValue); } return(result); }
/// <summary> /// Builds an operation that gets the value of a cell. /// </summary> /// <typeparam name="TValue">The type of value.</typeparam> /// <param name="cellLocator">The cell locator.</param> /// <returns> /// The operation. /// </returns> public static GetCellValueOp <TValue> GetValue <TValue>( this CellLocatorBase cellLocator) { var result = new GetCellValueOp <TValue>(Op.Const(cellLocator)); return(result); }
protected override OperationBase DeepCloneInternal() { var result = new GetCellValueOp <TResult>( this.CellLocator?.DeepClone(), this.DefaultValue?.DeepClone()); return(result); }
public GetCellValueOp <TResult> DeepCloneWithDefaultValue(IReturningOperation <TResult> defaultValue) { var result = new GetCellValueOp <TResult>( this.CellLocator?.DeepClone(), defaultValue); return(result); }
public override LocatedCellOpBase <TResult> DeepCloneWithCellLocator(IReturningOperation <CellLocatorBase> cellLocator) { var result = new GetCellValueOp <TResult>( cellLocator, this.DefaultValue?.DeepClone()); return(result); }
/// <inheritdoc /> public bool Equals(GetCellValueOp <TResult> other) { if (ReferenceEquals(this, other)) { return(true); } if (ReferenceEquals(other, null)) { return(false); } var result = this.CellLocator.IsEqualTo(other.CellLocator) && this.DefaultValue.IsEqualTo(other.DefaultValue); return(result); }