internal void SetIndexedPropertyValue(Object[] arguments, Object value){
if (this.obj == null)
throw new JScriptException(JSError.ObjectExpected);
if (this.name == null){
this.SetIndexedDefaultPropertyValue(this.obj, arguments, value);
return;
}
MemberInfo member = this.BindToMember(); //Do a GetMember call and remember the result of the lookup for next time around
//If the object has any members called this.name, we try to find a suitable indexed property.
if (this.last_members != null && this.last_members.Length > 0){
PropertyInfo prop = JSBinder.SelectProperty(Runtime.TypeRefs, this.last_members, arguments);
if (prop != null){
if (arguments.Length > 0 && prop.GetIndexParameters().Length == 0
){
//Might be a parameterless property that results in an object that has a indexed property that can be assigned to
MethodInfo getter = JSProperty.GetGetMethod(prop, false);
if (getter != null){
LateBinding.SetIndexedPropertyValueStatic(getter.Invoke(this.obj, null), arguments, value);
return;
}
}
arguments = LateBinding.LickArgumentsIntoShape(prop.GetIndexParameters(), arguments, JSBinder.ob, null);
value = Convert.CoerceT(value, prop.PropertyType);
JSProperty.SetValue(prop, this.obj, value, arguments);
return;
}
}
TypeCode tcode = Convert.GetTypeCode(obj);
if (Convert.NeedsWrapper(tcode)) return; //senseless assignment to implicit wrapper. Do nothing.
IReflect ir = LateBinding.GetIRForObjectThatRequiresInvokeMember(obj, this.checkForDebugger, tcode);
if (ir != null){
int n = arguments.Length + 1;
Object[] newargs = new Object[n];
ArrayObject.Copy(arguments, 0, newargs, 0, n-1);
newargs[n-1] = value;
const BindingFlags flags =
BindingFlags.Public|BindingFlags.Instance|BindingFlags.OptionalParamBinding|
BindingFlags.SetProperty|BindingFlags.SetField;
ir.InvokeMember(this.name, flags, JSBinder.ob, this.obj, newargs, null, null, null);
return;
}
//<ob.foo> might be an object that has a default indexed property
Object ob = this.GetValue();
if (ob != null && !(ob is Missing)){
this.SetIndexedDefaultPropertyValue(ob, arguments, value);
return;
}
//Give up
throw new JScriptException(JSError.OLENoPropOrMethod);
}