protected override void GetNamedArguments(out IList <DynamicMetaObject> namedArgs, out IList <string> argNames) { if (_signature.HasNamedArgument() || _signature.HasDictionaryArgument()) { var objects = new List <DynamicMetaObject>(); var names = new List <string>(); for (int i = 0; i < _signature.ArgumentCount; i++) { if (_signature.GetArgumentKind(i) == ArgumentType.Named) { objects.Add(GetArgument(i)); names.Add(_signature.GetArgumentName(i)); } } if (_signature.HasDictionaryArgument()) { if (objects == null) { objects = new List <DynamicMetaObject>(); names = new List <string>(); } SplatDictionaryArgument(names, objects); } names.TrimExcess(); objects.TrimExcess(); argNames = names; namedArgs = objects; } else { argNames = ArrayUtils.EmptyStrings; namedArgs = DynamicMetaObject.EmptyMetaObjects; } }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")] // TODO: fix private static MetaObject[] GetArgumentTypes(CallSignature signature, IList <MetaObject> args) { List <MetaObject> res = new List <MetaObject>(); List <MetaObject> namedObjects = null; for (int i = 0; i < args.Count; i++) { switch (signature.GetArgumentKind(i)) { case ArgumentType.Named: if (namedObjects == null) { namedObjects = new List <MetaObject>(); } namedObjects.Add(args[i]); break; case ArgumentType.Simple: case ArgumentType.Instance: res.Add(args[i]); break; case ArgumentType.List: IList <object> list = args[i].Value as IList <object>; if (list == null) { return(null); } for (int j = 0; j < list.Count; j++) { res.Add( new MetaObject( Ast.Call( Ast.Convert( args[i].Expression, typeof(IList <object>) ), typeof(IList <object>).GetMethod("get_Item"), Ast.Constant(j) ), args[i].Restrictions, list[j] ) ); } break; case ArgumentType.Dictionary: // caller needs to process these... break; default: throw new NotImplementedException(); } } if (namedObjects != null) { res.AddRange(namedObjects); } return(res.ToArray()); }