public virtual FieldInfo[] GetFields(BindingFlags bindingAttr) { ArrayObject arr = this as ArrayObject; if (arr != null && arr.denseArrayLength > 0) { //Interop fails to see elements unless they are returned in a GetXXXs call. An element in //the sparse portion of the array is returned as a FieldInfo. When interop asks for these //migrate the elements stored in the dense portion of the array to the sparse portion so that //they will be accessible. uint i, length; length = arr.denseArrayLength; if (length > arr.len) { length = arr.len; } for (i = 0; i < length; i++) { Object element = arr.denseArray[i]; if (element != Missing.Value) { arr.SetMemberValue2(i.ToString(), element); //Implemented on JSObject and bypasses length checking } } arr.denseArrayLength = 0; arr.denseArray = null; } MemberInfo[] members = this.GetMembers(bindingAttr); if (members == null) { return(new FieldInfo[0]); } int fieldCount = 0; foreach (MemberInfo member in members) { if (member.MemberType == MemberTypes.Field) { fieldCount++; } } FieldInfo[] fields = new FieldInfo[fieldCount]; fieldCount = 0; foreach (MemberInfo member in members) { if (member.MemberType == MemberTypes.Field) { fields[fieldCount++] = (FieldInfo)member; } } return(fields); }
public virtual FieldInfo[] GetFields(BindingFlags bindingAttr) { ArrayObject obj2 = this as ArrayObject; if ((obj2 != null) && (obj2.denseArrayLength > 0)) { uint denseArrayLength = obj2.denseArrayLength; if (denseArrayLength > obj2.len) { denseArrayLength = obj2.len; } for (uint i = 0; i < denseArrayLength; i++) { object obj3 = obj2.denseArray[i]; if (obj3 != Microsoft.JScript.Missing.Value) { obj2.SetMemberValue2(i.ToString(CultureInfo.InvariantCulture), obj3); } } obj2.denseArrayLength = 0; obj2.denseArray = null; } MemberInfo[] members = this.GetMembers(bindingAttr); if (members == null) { return(new FieldInfo[0]); } int num3 = 0; foreach (MemberInfo info in members) { if (info.MemberType == MemberTypes.Field) { num3++; } } FieldInfo[] infoArray2 = new FieldInfo[num3]; num3 = 0; foreach (MemberInfo info2 in members) { if (info2.MemberType == MemberTypes.Field) { infoArray2[num3++] = (FieldInfo)info2; } } return(infoArray2); }