예제 #1
0
        /// <summary>
        /// Begins an asynchronous tabulation of the
        /// expression with giving three argument ranges.</summary>
        /// <param name="range1">First argument range.</param>
        /// <param name="range2">Second argument range.</param>
        /// <param name="range3">Third argument range.</param>
        /// <param name="callback">
        /// The <see cref="AsyncCallback"/> delegate.</param>
        /// <param name="state">An object that contains
        /// state information for this tabulation.</param>
        /// <exception cref="InvalidRangeException"><paramref name="range1"/>,
        /// <paramref name="range2"/> or <paramref name="range3"/>
        /// is not valid for iteration over it.</exception>
        /// <exception cref="ArgumentException"><see cref="Interpret{T}"/>
        /// can't tabulate expression with three ranges given, you should specify
        /// valid <see cref="ArgumentsCount">arguments count</see>.</exception>
        /// <exception cref="ArithmeticException">Expression evaluation
        /// thrown the <see cref="ArithmeticException"/>.</exception>
        /// <returns>An <see cref="IAsyncResult"/> that references
        /// the asynchronous tabulation result.</returns>
        public IAsyncResult BeginTabulate(
            ValueRange <T> range1,
            ValueRange <T> range2,
            ValueRange <T> range3,
            AsyncCallback callback,
            object state)
        {
            if (this.argsCount != 3)
            {
                throw WrongRangesCount(3);
            }

            Array array = Interpret.Allocate(range1, range2, range3);

#if FULL_FW
            return(((TabFuncN)this.asyncTab)
                   .BeginInvoke(array,
                                new[] { range1, range2, range3 },
                                callback, state));
#else
            return(new AsyncHelper <Array>(() =>
                                           TabNImpl(array, range1, range2, range3),
                                           callback, state));
#endif
        }
예제 #2
0
        /// <summary>
        /// Invokes interpreter to tabulate the expression
        /// with the specified argument <paramref name="ranges"/>.</summary>
        /// <param name="ranges">Argument ranges.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="ranges"/> is null.</exception>
        /// <exception cref="InvalidRangeException">
        /// Some instance of <paramref name="ranges"/>
        /// is not valid for iteration over it.</exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="ranges"/> doesn't specify needed
        /// <see cref="ArgumentsCount">ranges count</see>.</exception>
        /// <exception cref="ArithmeticException">Expression evaluation
        /// thrown the <see cref="ArithmeticException"/>.</exception>
        /// <returns><see cref="ArgumentsCount">N</see>-dimensional jagged array
        /// of the evaluated values casted to <see cref="Array"/> type.</returns>
        public Array Tabulate(params ValueRange <T>[] ranges)
        {
            if (ranges == null || ranges.Length != this.argsCount)
            {
                throw WrongRangesCount(ranges);
            }

            Array array = Interpret.Allocate(ranges);

            TabNImpl(array, ranges);

            return(array);
        }
예제 #3
0
        /// <summary>
        /// Invokes interpreter to tabulate the expression
        /// with giving two argument ranges.</summary>
        /// <param name="range1">First argument range.</param>
        /// <param name="range2">Second argument range.</param>
        /// <param name="range3">Third argument range.</param>
        /// <exception cref="InvalidRangeException"><paramref name="range1"/>,
        /// <paramref name="range2"/> or <paramref name="range3"/>
        /// is not valid for iteration over it.</exception>
        /// <exception cref="ArgumentException"><see cref="Interpret{T}"/>
        /// can't tabulate expression with two ranges given, you should specify
        /// valid <see cref="ArgumentsCount">arguments count</see>.</exception>
        /// <exception cref="ArithmeticException">Expression evaluation
        /// thrown the <see cref="ArithmeticException"/>.</exception>
        /// <returns>Three-dimensional jagged array of the evaluated values
        /// casted to <see cref="Array"/> type.</returns>
        public Array Tabulate(
            ValueRange <T> range1,
            ValueRange <T> range2,
            ValueRange <T> range3)
        {
            if (this.argsCount != 3)
            {
                throw WrongRangesCount(3);
            }

            Array array = Interpret.Allocate(range1, range2, range3);

            return(TabNImpl(array, range1, range2, range3));
        }
예제 #4
0
        /// <summary>
        /// Generates the <see cref="Interpret{T}"/>
        /// object for evaluating the specified
        /// <paramref name="expression"/>.</summary>
        /// <param name="expression">Expression to create
        /// <see cref="Interpret{T}"/> from.</param>
        /// <exception cref="SyntaxException">
        /// <paramref name="expression"/> contains
        /// syntax error(s) and can't be used for the
        /// <see cref="Interpret{T}"/> creation.</exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="expression"/> is null.</exception>
        /// <returns><see cref="Interpret{T}"/> object
        /// for evaluating expression.</returns>
        public Interpret <T> CreateInterpret(string expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            var creator = new InterpretCreator <T>();

            ParseOptimized(expression, creator);

            return(Interpret <T> .Create(
                       OverflowCheck, expression, ArgsCount, creator));
        }
예제 #5
0
        /// <summary>
        /// Begins an asynchronous tabulation of the expression
        /// with specified argument <paramref name="ranges"/>.</summary>
        /// <param name="ranges">Argument ranges.</param>
        /// <param name="callback">
        /// The <see cref="AsyncCallback"/> delegate.</param>
        /// <param name="state">An object that contains
        /// state information for this tabulation.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="ranges"/> is null.</exception>
        /// <exception cref="InvalidRangeException">
        /// Some instance of <paramref name="ranges"/>
        /// is not valid for iteration over it.</exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="ranges"/> doesn't specify needed
        /// <see cref="ArgumentsCount">ranges count</see>.</exception>
        /// <exception cref="ArithmeticException">Expression evaluation
        /// thrown the <see cref="ArithmeticException"/>.</exception>
        /// <returns><see cref="ArgumentsCount">N</see>-dimensional jagged array
        /// of the evaluated values casted to <see cref="Array"/> type.</returns>
        public IAsyncResult BeginTabulate(
            ValueRange <T>[] ranges,
            AsyncCallback callback,
            object state)
        {
            if (ranges == null ||
                ranges.Length != this.argsCount)
            {
                throw WrongRangesCount(ranges);
            }

            Array array = Interpret.Allocate(ranges);

#if FULL_FW
            return(((TabFuncN)this.asyncTab)
                   .BeginInvoke(array, ranges, callback, state));
#else
            return(new AsyncHelper <Array>(() =>
                                           TabNImpl(array, ranges), callback, state));
#endif
        }