예제 #1
0
        /// <summary>
        /// Builds an <see cref="GetAvailabilityOp"/>.
        /// </summary>
        /// <param name="cellLocator">The cell locator.</param>
        /// <returns>
        /// The operation.
        /// </returns>
        public static GetAvailabilityOp GetAvailability(
            this CellLocatorBase cellLocator)
        {
            var result = new GetAvailabilityOp(Op.Const(cellLocator));

            return(result);
        }
예제 #2
0
        /// <inheritdoc />
        public async Task <Availability> ExecuteAsync(
            GetAvailabilityOp 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 recalcPhase = this.getRecalcPhaseFunc();

            if (recalcPhase != RecalcPhase.AvailabilityCheck)
            {
                throw new InvalidOperationException(Invariant($"Cannot execute {nameof(GetAvailabilityOp)} during the {recalcPhase} phase."));
            }

            var cell = await this.GetCellAndCheckAvailabilityIfNecessaryAsync(operation.CellLocator);

            var result = cell.GetAvailability();

            return(result);
        }