internal static Object GetValueAtIndex(Object obj, ulong index){
if (obj is ScriptObject)
if (index < UInt32.MaxValue)
return ((ScriptObject)obj).GetValueAtIndex((uint)index);
else
return ((ScriptObject)obj).GetMemberValue(index.ToString(CultureInfo.InvariantCulture));
default_property_case:
if (obj is IList)
checked {return ((IList)obj)[(int)index];}
if (obj is Array)
checked {return ((Array)obj).GetValue((int)index);}
Type type = obj.GetType();
if (type.IsCOMObject || obj is IReflect || index > Int32.MaxValue)
return LateBinding.GetMemberValue(obj, index.ToString(CultureInfo.InvariantCulture));
//Assume that the object does not itself have a field/property with numerical name.
//See if the object has a default indexed property, or default property that results in an Array or List and work with that.
MethodInfo getter = JSBinder.GetDefaultPropertyForArrayIndex(type, (int)index, null, false);
if (getter != null){
ParameterInfo[] pars = getter.GetParameters();
if (pars == null || pars.Length == 0){
obj = getter.Invoke(obj, BindingFlags.SuppressChangeType, null, null, null);
goto default_property_case;
}else
return getter.Invoke(obj, (BindingFlags)0, JSBinder.ob, new Object[]{(int)index}, null);
}
return Missing.Value;
}