protected override object TryInvoke(InvokeBinder binder, object[] arguments) { var argsIdx = 0; var left = Length; var combinedIdx = 0; var combined = new List<object>(); var argumentsLength = Currying.Arity(arguments); while (combinedIdx < received.Length || argsIdx < argumentsLength) { object result = null; if (combinedIdx < received.Length && (!IsPlaceholder(received[combinedIdx]) || argsIdx >= argumentsLength)) { result = received[combinedIdx]; } else { result = arguments[argsIdx]; argsIdx += 1; } combined.Insert(combinedIdx, result); if (!IsPlaceholder(result)) { left -= 1; } combinedIdx += 1; } return left <= 0 ? Reflection.DynamicInvoke(fn, combined.ToArray()) : Currying.Arity(left, new CurryN(fn, combined.ToArray(), Length)); }
internal static object CloneAndAssignValue(dynamic prop, object propValue, object obj) { object target = null; var type = obj.GetType(); if (type.IsAnonymousType()) { target = AnonymousTypeCloneAndAssignValue(prop, propValue, type, obj); } else { MemberInfo memberInfo = Reflection.TryGetMemberInfoFromType(type, prop); if (memberInfo != null && memberInfo.GetUnderlyingType().IsAssignableFrom(propValue.GetType())) { target = WellKnownTypeCloneAndAssignValue(prop, obj, propValue); } else { IDictionary <string, object> expando = Reflection.ToExpando(obj); expando[prop] = propValue; target = expando; } } return(target); }
public object DynamicInvoke(params object[] arguments) { return(Reflection.DynamicInvoke((dynamic)this, arguments)); }
public TResult DynamicInvoke <TResult>(params object[] arguments) { return((TResult)Reflection.DynamicInvoke((dynamic)this, arguments)); }
internal static int Arity(this Delegate @delegate) { return(Reflection.FunctionArity(@delegate)); }
internal static IList Arguments(params object[] arguments) { return(Reflection.Arity(arguments)); }