|
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,42 @@ 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[] props = new string[count]; |
| 1127 | + |
| 1128 | + for (int i = 0; i < count; ++i) |
| 1129 | + { |
| 1130 | + ListViewField lvf = lve.listViewFieldList[i]; |
| 1131 | + props[i] = lvf.label ?? lvf.propertyName; |
| 1132 | + } |
| 1133 | + |
| 1134 | + return props; |
1131 | 1135 | }
|
1132 | 1136 |
|
1133 | 1137 | internal static string[] GetValues(ListViewEntry lve)
|
1134 | 1138 | {
|
1135 |
| - StringCollection vals = new StringCollection(); |
| 1139 | + int count = lve.listViewFieldList.Count; |
1136 | 1140 |
|
1137 |
| - foreach (ListViewField lvf in lve.listViewFieldList) |
| 1141 | + if (count == 0) |
1138 | 1142 | {
|
1139 |
| - vals.Add(lvf.formatPropertyField.propertyValue); |
| 1143 | + return null; |
1140 | 1144 | }
|
1141 | 1145 |
|
1142 |
| - if (vals.Count == 0) |
1143 |
| - return null; |
1144 |
| - string[] retVal = new string[vals.Count]; |
1145 |
| - vals.CopyTo(retVal, 0); |
1146 |
| - return retVal; |
| 1146 | + string[] vals = new string[count]; |
| 1147 | + |
| 1148 | + for (int i = 0; i < count; ++i) |
| 1149 | + { |
| 1150 | + ListViewField lvf = lve.listViewFieldList[i]; |
| 1151 | + vals[i] = lvf.formatPropertyField.propertyValue; |
| 1152 | + } |
| 1153 | + |
| 1154 | + return vals; |
1147 | 1155 | }
|
1148 | 1156 |
|
1149 | 1157 | /// <summary>
|
|
0 commit comments