private void SplatDictionaryArgument(IList <string> splattedNames, IList <DynamicMetaObject> splattedArgs) { Assert.NotNull(splattedNames, splattedArgs); Debug.Assert(_signature.HasDictionaryArgument()); DynamicMetaObject dictMo = GetArgument(_signature.IndexOf(ArgumentType.Dictionary)); IDictionary dict = (IDictionary)dictMo.Value; IDictionaryEnumerator dictEnum = dict.GetEnumerator(); while (dictEnum.MoveNext()) { DictionaryEntry de = dictEnum.Entry; string strKey = de.Key is string s ? s : de.Key is Extensible <string> es ? es.Value : null; if (strKey != null) { splattedNames.Add(strKey); splattedArgs.Add( DynamicMetaObject.Create( de.Value, Ast.Call( AstUtils.Convert(dictMo.Expression, typeof(IDictionary)), typeof(IDictionary).GetMethod("get_Item"), AstUtils.Constant(strKey) ) ) ); } } }
/// <summary> /// Pulls out the right argument to build the splat test. MakeParamsTest makes the actual test. /// </summary> private static BindingRestrictions MakeParamsArrayTest(CallTypes callType, CallSignature signature, bool testTypes, IList <DynamicMetaObject> args) { int listIndex = signature.IndexOf(ArgumentType.List); Debug.Assert(listIndex != -1); if (callType == CallTypes.ImplicitInstance) { listIndex++; } return(MakeParamsTest(args[listIndex], testTypes)); }