|
3 | 3 |
|
4 | 4 | using System; |
5 | 5 | using System.Collections.Generic; |
6 | | -using System.Collections.Specialized; |
7 | 6 | using System.Management.Automation; |
8 | 7 | using System.Management.Automation.Internal; |
9 | 8 |
|
@@ -1117,33 +1116,40 @@ private void InternalInitialize(ListViewEntry lve) |
1117 | 1116 |
|
1118 | 1117 | internal static string[] GetProperties(ListViewEntry lve) |
1119 | 1118 | { |
1120 | | - StringCollection props = new StringCollection(); |
1121 | | - foreach (ListViewField lvf in lve.listViewFieldList) |
| 1119 | + int count = lve.listViewFieldList.Count; |
| 1120 | + |
| 1121 | + if (count == 0) |
1122 | 1122 | { |
1123 | | - props.Add(lvf.label ?? lvf.propertyName); |
| 1123 | + return null; |
1124 | 1124 | } |
1125 | 1125 |
|
1126 | | - if (props.Count == 0) |
1127 | | - return null; |
1128 | | - string[] retVal = new string[props.Count]; |
1129 | | - props.CopyTo(retVal, 0); |
1130 | | - return retVal; |
| 1126 | + string[] result = new string[count]; |
| 1127 | + for (int index = 0; index < result.Length; ++index) |
| 1128 | + { |
| 1129 | + ListViewField lvf = lve.listViewFieldList[index]; |
| 1130 | + result[index] = lvf.label ?? lvf.propertyName; |
| 1131 | + } |
| 1132 | + |
| 1133 | + return result; |
1131 | 1134 | } |
1132 | 1135 |
|
1133 | 1136 | internal static string[] GetValues(ListViewEntry lve) |
1134 | 1137 | { |
1135 | | - StringCollection vals = new StringCollection(); |
| 1138 | + int count = lve.listViewFieldList.Count; |
1136 | 1139 |
|
1137 | | - foreach (ListViewField lvf in lve.listViewFieldList) |
| 1140 | + if (count == 0) |
1138 | 1141 | { |
1139 | | - vals.Add(lvf.formatPropertyField.propertyValue); |
| 1142 | + return null; |
1140 | 1143 | } |
1141 | 1144 |
|
1142 | | - if (vals.Count == 0) |
1143 | | - return null; |
1144 | | - string[] retVal = new string[vals.Count]; |
1145 | | - vals.CopyTo(retVal, 0); |
1146 | | - return retVal; |
| 1145 | + string[] result = new string[count]; |
| 1146 | + for (int index = 0; index < result.Length; ++index) |
| 1147 | + { |
| 1148 | + ListViewField lvf = lve.listViewFieldList[index]; |
| 1149 | + result[index] = lvf.formatPropertyField.propertyValue; |
| 1150 | + } |
| 1151 | + |
| 1152 | + return result; |
1147 | 1153 | } |
1148 | 1154 |
|
1149 | 1155 | /// <summary> |
|
0 commit comments