private SetValue ( Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object index, |
||
obj | Object | |
value | Object | |
invokeAttr | BindingFlags | |
binder | Binder | |
index | Object | |
culture | ||
Результат | void |
internal static void SetValue(PropertyInfo prop, object obj, object value, object[] index) { JSProperty property = prop as JSProperty; if (property != null) { property.SetValue(obj, value, BindingFlags.ExactBinding, null, index, null); } else { MethodInfo setMethod = GetSetMethod(prop, false); if (setMethod == null) { throw new MissingMethodException(); } int n = (index == null) ? 0 : index.Length; object[] target = new object[n + 1]; if (n > 0) { ArrayObject.Copy(index, 0, target, 0, n); } target[n] = value; setMethod.Invoke(obj, BindingFlags.ExactBinding, null, target, null); } }
internal override void SetMemberValue(string name, object value) { bool flag = false; if (!this.recursive) { this.recursive = true; try { FieldInfo field = this.reflectObj.GetField(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (field == null) { PropertyInfo property = this.reflectObj.GetProperty(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); if (property != null) { JSProperty.SetValue(property, this.namedItem, value, null); flag = true; } } else { field.SetValue(this.namedItem, value); flag = true; } if (!flag && (base.parent != null)) { base.parent.SetMemberValue(name, value); } } finally { this.recursive = false; } } }
internal override void SetMemberValue(String name, Object value) { bool assigned = false; if (!this.recursive) { this.recursive = true; try{ FieldInfo field = this.reflectObj.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public); if (field == null) { PropertyInfo prop = this.reflectObj.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public); if (prop != null) { JSProperty.SetValue(prop, this.namedItem, value, null); assigned = true; } } else { field.SetValue(this.namedItem, value); assigned = true; } if (!assigned && null != parent) { parent.SetMemberValue(name, value); } }finally{ this.recursive = false; } } }
internal override object Evaluate() { ConstructorInfo member = (ConstructorInfo)((Binding)this.ctor).member; ParameterInfo[] parameters = member.GetParameters(); int length = parameters.Length; for (int i = this.positionalArgValues.Count; i < length; i++) { this.positionalArgValues.Add(Microsoft.JScript.Convert.CoerceT(null, parameters[i].ParameterType)); } object[] array = new object[length]; this.positionalArgValues.CopyTo(0, array, 0, length); object obj2 = member.Invoke(BindingFlags.ExactBinding, null, array, null); int num3 = 0; int count = this.namedArgProperties.Count; while (num3 < count) { JSProperty property = this.namedArgProperties[num3] as JSProperty; if (property != null) { property.SetValue(obj2, Microsoft.JScript.Convert.Coerce(this.namedArgPropertyValues[num3], property.PropertyIR()), null); } else { ((PropertyInfo)this.namedArgProperties[num3]).SetValue(obj2, this.namedArgPropertyValues[num3], null); } num3++; } int num5 = 0; int num6 = this.namedArgFields.Count; while (num5 < num6) { JSVariableField field = this.namedArgFields[num5] as JSVariableField; if (field != null) { field.SetValue(obj2, Microsoft.JScript.Convert.Coerce(this.namedArgFieldValues[num5], field.GetInferredType(null))); } else { ((FieldInfo)this.namedArgFields[num5]).SetValue(obj2, this.namedArgFieldValues[num5]); } num5++; } return(obj2); }
internal override Object Evaluate() { ConstructorInfo c = (ConstructorInfo)((Binding)this.ctor).member; ParameterInfo[] pars = c.GetParameters(); int pn = pars.Length; for (int i = positionalArgValues.Count; i < pn; i++) { positionalArgValues.Add(Convert.CoerceT(null, pars[i].ParameterType)); } Object[] pArgVals = new Object[pn]; positionalArgValues.CopyTo(0, pArgVals, 0, pn); Object ca = c.Invoke(BindingFlags.ExactBinding, null, pArgVals, null); for (int i = 0, n = this.namedArgProperties.Count; i < n; i++) { JSProperty prop = this.namedArgProperties[i] as JSProperty; if (prop != null) { prop.SetValue(ca, Convert.Coerce(this.namedArgPropertyValues[i], prop.PropertyIR()), null); } else { ((PropertyInfo)this.namedArgProperties[i]).SetValue(ca, this.namedArgPropertyValues[i], null); } } for (int i = 0, n = this.namedArgFields.Count; i < n; i++) { JSVariableField field = this.namedArgFields[i] as JSVariableField; if (field != null) { field.SetValue(ca, Convert.Coerce(this.namedArgFieldValues[i], field.GetInferredType(null))); } else { ((FieldInfo)this.namedArgFields[i]).SetValue(ca, this.namedArgFieldValues[i]); } } return(ca); }