Esempio n. 1
0
        /// <summary>
        /// Adds the static method reflection taken from the specified
        /// <paramref name="type"/> by the <paramref name="methodName"/>
        /// in the <see cref="FunctionCollection{T}"/> with the
        /// function name, taken from real method name.</summary>
        /// <param name="methodName">
        /// Type's method name to be imported.</param>
        /// <param name="type">Type object.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="type"/> is null.<br/>-or-<br/>
        /// <paramref name="methodName"/>is null.</exception>
        /// <exception cref="ArgumentException">Method with
        /// <paramref name="methodName"/> is not founded.
        /// <br/>-or-<br/>Founded method is not valid to be
        /// added into this <see cref="FunctionCollection{T}"/>.
        /// <br/>-or-<br/><see cref="FunctionInfo{T}"/> with
        /// same name and the same arguments count already exist
        /// in the collection (overload impossible).</exception>
        /// <exception cref="System.Reflection.AmbiguousMatchException">
        /// <paramref name="type"/> contains more than one methods
        /// matching the specified <paramref name="methodName"/>.
        /// </exception>
        public void Import(string methodName, Type type)
        {
            var method = FunctionFactory <T>
                         .TryResolve(type, methodName, -1);

            Validator.CheckVisible(method);

            AddFunc(FunctionFactory <T>
                    .FromReflection(method, null, true));
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the static method reflection taken from the specified
        /// <paramref name="type"/> by the <paramref name="methodName"/>
        /// and arguments count to the <see cref="FunctionCollection{T}"/>
        /// with the function name, taken from real method name.</summary>
        /// <param name="type">Type object.</param>
        /// <param name="methodName">Type's method name to be imported.</param>
        /// <param name="parametersCount">Method parameters count.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="type"/> is null.<br/>-or-<br/>
        /// <paramref name="methodName"/>is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="parametersCount"/> is less than 0.</exception>
        /// <exception cref="ArgumentException">
        /// Method with <paramref name="methodName"/> is not founded.
        /// <br/>-or-<br/>Founded method is not valid to be added
        /// to the <see cref="FunctionCollection{T}"/>.
        /// <br/>-or-<br/><see cref="FunctionInfo{T}"/>
        /// with the same name and the same arguments count already
        /// exist in the collection (overload impossible).</exception>
        public void Import(
            string methodName, Type type, int parametersCount)
        {
            if (parametersCount < 0)
            {
                throw new ArgumentOutOfRangeException("parametersCount");
            }

            var method = FunctionFactory <T> .TryResolve(
                type, methodName, parametersCount);

            Validator.CheckVisible(method);

            AddFunc(FunctionFactory <T>
                    .FromReflection(method, null, true));
        }