Exemple #1
0
        /// <summary>
        /// 関数オブジェクトの呼び出し
        /// </summary>
        /// <param name="arguments">関数オブジェクトの処理の引数</param>
        /// <returns>関数オブジェクトの処理の戻り値</returns>
        /// <exception cref="UnmatchArgumentException">引数の数と型があわない場合はこの例外を投げる</exception>
        public object Invoke(params object[] arguments)
        {
            ArrayList list = new ArrayList();

            foreach (object arg in boundArguments)
            {
                NotBoundArgument notBoundArgument = arg as NotBoundArgument;
                if (notBoundArgument != null)
                {
                    if (arguments.Length <= notBoundArgument.Index)
                    {
                        throw new UnmatchArgumentException();
                    }
                    list.Add(arguments[notBoundArgument.Index]);
                    continue;
                }

                IArgumentProvider provider = arg as IArgumentProvider;
                if (provider != null)
                {
                    list.Add(provider.Provide());
                    continue;
                }

                list.Add(arg);
            }
            return(internalFunctor.Invoke(list.ToArray()));
        }
Exemple #2
0
        /// <summary>
        /// 関数オブジェクトの呼び出し
        /// </summary>
        /// <returns>関数オブジェクトの処理の戻り値</returns>
        /// <exception cref="UnmatchArgumentException">引数の数と型があわない場合はこの例外を投げる</exception>
        public object Invoke()
        {
            ArrayList list = new ArrayList();

            foreach (object arg in boundArguments)
            {
                if (arg is NotBoundArgument)
                {
                    throw new UnmatchArgumentException();
                }

                IArgumentProvider provider = arg as IArgumentProvider;
                if (provider != null)
                {
                    list.Add(provider.Provide());
                    continue;
                }

                list.Add(arg);
            }
            return(internalFunctor.Invoke(list.ToArray()));
        }