internal void SetIndexedDefaultPropertyValue(Object ob, Object[] arguments, Object value){
ScriptObject scrob = ob as ScriptObject;
if (scrob != null){
scrob[arguments] = value;
return;
}
System.Array arr = ob as System.Array;
if (arr != null){
if (arguments.Length != arr.Rank)
throw new JScriptException(JSError.IncorrectNumberOfIndices);
arr.SetValue(value, LateBinding.ToIndices(arguments));
return;
}
TypeCode tcode = Convert.GetTypeCode(ob);
if (Convert.NeedsWrapper(tcode)) return; //senseless assignment to implicit wrapper. Do nothing.
IReflect ir = LateBinding.GetIRForObjectThatRequiresInvokeMember(ob, this.checkForDebugger, tcode);
if (ir != null){
try{
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(String.Empty, flags, JSBinder.ob, ob, newargs, null, null, null);
return;
}catch(MissingMemberException){
throw new JScriptException(JSError.OLENoPropOrMethod);
}
}
MemberInfo[] defaultMembers = TypeReflector.GetTypeReflectorFor(ob.GetType()).GetDefaultMembers();
if (defaultMembers != null && defaultMembers.Length > 0){
PropertyInfo prop = JSBinder.SelectProperty(Runtime.TypeRefs, defaultMembers, arguments);
if (prop != null){
MethodInfo setter = JSProperty.GetSetMethod(prop, false);
if (setter != null){
arguments = LateBinding.LickArgumentsIntoShape(prop.GetIndexParameters(), arguments, JSBinder.ob, null);
value = Convert.CoerceT(value, prop.PropertyType);
int n = arguments.Length + 1;
Object[] newargs = new Object[n];
ArrayObject.Copy(arguments, 0, newargs, 0, n-1);
newargs[n-1] = value;
setter.Invoke(ob, newargs);
return;
}
}
}
throw new JScriptException(JSError.OLENoPropOrMethod);
}