private void BuildMemberTypeIndexInformation(MemberTypeIndexPair[] memberTypeIndexPairs, IEnumerable propertyInfos, IEnumerable fieldInfos) { for (int i = 0; i < Headers.Length; i++) { memberTypeIndexPairs[i].Index = -1; #region See if the header at index i is a field int j = 0; foreach (FieldInfo fieldInfo in fieldInfos) { if (fieldInfo.Name == Headers[i].Name) { Headers[i].MemberTypes = MemberTypes.Field; memberTypeIndexPairs[i] = new MemberTypeIndexPair(); memberTypeIndexPairs[i].Index = j; memberTypeIndexPairs[i].MemberType = MemberTypes.Field; break; } j++; } if (memberTypeIndexPairs[i].Index != -1 && memberTypeIndexPairs[i].MemberType == MemberTypes.Field) { continue; } #endregion #region If we got this far, then it's not a field, so check if it's a property j = 0; foreach (PropertyInfo propertyInfo in propertyInfos) { if (propertyInfo.Name == Headers[i].Name) { Headers[i].MemberTypes = MemberTypes.Property; memberTypeIndexPairs[i] = new MemberTypeIndexPair(); memberTypeIndexPairs[i].Index = j; memberTypeIndexPairs[i].MemberType = MemberTypes.Property; break; } j++; } if (memberTypeIndexPairs[i].Index != -1 && memberTypeIndexPairs[i].MemberType == MemberTypes.Property) { continue; } #endregion // Is this needed: memberTypeIndexPairs[i].Index = -1; } }
private void GetReflectionInformation(Type typeOfElement, out MemberTypeIndexPair[] memberTypeIndexPairs, out IEnumerable <PropertyInfo> propertyInfos, out IEnumerable <FieldInfo> fieldInfos) { memberTypeIndexPairs = new MemberTypeIndexPair[Headers.Length]; propertyInfos = typeOfElement.GetProperties(); fieldInfos = typeOfElement.GetFields(); RemoveHeaderWhitespaceAndDetermineIfRequired(); BuildMemberTypeIndexInformation(memberTypeIndexPairs, propertyInfos, fieldInfos); }