Beispiel #1
0
        /// <summary>
        /// Builds an <see cref="SumOp"/>.
        /// </summary>
        /// <param name="statements">The statements.</param>
        /// <returns>
        /// The operation.
        /// </returns>
        public static SumOp Sum(
            params IReturningOperation <decimal>[] statements)
        {
            var result = new SumOp(statements);

            return(result);
        }
Beispiel #2
0
        /// <inheritdoc />
        public decimal Execute(
            SumOp operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            var result = operation.Statements.Sum(_ => this.protocolFactory.GetProtocolAndExecuteViaReflection <decimal>(_));

            return(result);
        }
Beispiel #3
0
        /// <inheritdoc />
        public async Task <decimal> ExecuteAsync(
            SumOp operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            var result = 0m;

            foreach (var statement in operation.Statements)
            {
                result = result + await this.protocolFactory.GetProtocolAndExecuteViaReflectionAsync <decimal>(statement);
            }

            return(result);
        }