コード例 #1
0
        private static int AscendDescendInternal(dynamic firstOperator, dynamic secondOprator, dynamic fn, dynamic a, dynamic b)
        {
            DynamicDelegate dynamicDelegate = Delegate(fn);

            var aa = dynamicDelegate.DynamicInvoke <dynamic>(a);
            var bb = dynamicDelegate.DynamicInvoke <dynamic>(b);

            return(firstOperator(aa, bb) ? -1 : secondOprator(aa, bb) ? 1 : 0);
        }
コード例 #2
0
        private static object BothOrEither(DynamicDelegate f, DynamicDelegate g, Func <Func <bool>, Func <bool>, bool> operand, dynamic liftBy)
        {
            if (f.IsNotNull())
            {
                return(Delegate((object[] arguments) => operand(() => f.DynamicInvoke <bool>(arguments), () => g.DynamicInvoke <bool>(arguments))));
            }

            return(Lift(liftBy)(f, g));
        }
コード例 #3
0
ファイル: XReduceBy.cs プロジェクト: sagifogel/Ramda.NET
        public object Step(object result, object input)
        {
            var key = keyFn(input);

            inputs[key] = inputs.ContainsKey(key) ? inputs[key] : new object[2] {
                key, valueAcc
            };
            inputs[key][1] = valueFn.DynamicInvoke(inputs[key][1], input);

            return(result);
        }
コード例 #4
0
        private static dynamic CreatePartialApplicator(DynamicDelegate concat)
        {
            return(Curry2(new Func <dynamic, IList, dynamic>((fn, args) => {
                return Arity(Math.Max(0, fn.Arity() - args.Count), Delegate((object[] arguments) => {
                    DynamicDelegate dynamicDelegate = Delegate(fn);
                    var concatedArgs = (IList)concat.DynamicInvoke(args, Arguments(arguments));

                    return dynamicDelegate.DynamicInvoke(concatedArgs.ToArray <object[]>(typeof(object)));
                }));
            })));
        }
コード例 #5
0
        private static IList TakeWhileInternal(int from, int indexerAcc, Func <int, bool> loopPredicate, DynamicDelegate fn, IList list, Func <int, int> sliceFrom, Func <int, int> sliceTo)
        {
            var idx = from;

            while (loopPredicate(idx) && fn.DynamicInvoke <bool>(list[idx]))
            {
                idx += indexerAcc;
            }

            return(list.Slice(sliceFrom(idx), sliceTo(idx)));
        }
コード例 #6
0
        private static IList DropLastWhileInternal(dynamic pred, IList list)
        {
            var             idx             = list.Count - 1;
            DynamicDelegate dynamicDelegate = Delegate(pred);

            while (idx >= 0 && dynamicDelegate.DynamicInvoke <bool>(list[idx]))
            {
                idx -= 1;
            }

            return(list.Slice(0, idx + 1));
        }
コード例 #7
0
        private static DynamicDelegate AnyOrAllPass(IList preds, bool comparend)
        {
            return(Delegate((object[] arguments) => {
                foreach (dynamic pred in preds)
                {
                    DynamicDelegate dynamicPred = Delegate(pred);

                    if (dynamicPred.DynamicInvoke <bool>(arguments) == comparend)
                    {
                        return comparend;
                    }
                }

                return !comparend;
            }));
        }
コード例 #8
0
 public PromiseContinuation Then(Func <dynamic, dynamic> continuation)
 {
     return(new PromiseContinuation(f.DynamicInvoke <dynamic>(arguments).Result).Then(continuation));
 }
コード例 #9
0
 private static dynamic ComplementInternal(DynamicDelegate fn)
 {
     return(Delegate((object[] arguments) => !fn.DynamicInvoke <bool>(arguments)));
 }