public override IEnumerable <KeyValuePair <Dynamic, Dynamic> > GetEnumerable() { if (handle is IDictionary) { foreach (DictionaryEntry entry in (IDictionary)handle) { yield return(new KeyValuePair <Dynamic, Dynamic>( DynamicFactory.CreateDynamic(entry.Key), DynamicFactory.CreateDynamic(entry.Value))); } } else if (handle is IEnumerable) { int index = 0; foreach (object item in (IEnumerable)handle) { yield return(new KeyValuePair <Dynamic, Dynamic>( new Integer(index++), DynamicFactory.CreateDynamic(item))); } } else { throw new InvalidOperationException(string.Format(Resources.IterationNotSupported, NativeType.FullName)); } }
public override Dynamic GetItem(Dynamic index) { const BindingFlags flags = BindingFlags.InvokeMethod | BindingFlags.OptionalParamBinding; object obj = NativeType.IsCOMObject ? NativeType.InvokeMember("Item", flags, null, handle, new[] { index.AsNativeObject }) : NativeType.InvokeMember("get_Item", flags, new DynamicBinder(), handle, new[] { index }); return(DynamicFactory.CreateDynamic(obj)); }