예제 #1
0
        public override double GetValue()
        {
            var function = _functionService.Get(Id);

            IEnumerable <object> args;

            if (_arguments.Length > function.RequiredParameterNumber)
            {
                args = function.ParameterTypes.Take(_arguments.Length)
                       .Select((type, i) => ConvertArgument(type, _arguments[i]))
                       .ToList();

                if (args.Count() < _arguments.Length)
                {
                    var batch = function.ParameterTypes.Skip(args.Count() - (function.ParameterBatchSize ?? 1)).ToArray();
                    args = args.Concat(_arguments.Skip(args.Count())
                                       .Select((arg, i) => ConvertArgument(batch[i % batch.Length], arg)))
                           .ToList();
                }
            }
            else
            {
                args = _arguments.Select((e, i) => function.ParameterTypes[i] == ArgumentType.Number ? (object)e.Resolve() : e);
            }

            return(_functionService.Execute(Id, args.ToArray()));
        }