@@ -86,8 +86,8 @@ public static async Task<List<CardProperty>> GetComputeSystemCardPropertiesAsync
86
86
{
87
87
try
88
88
{
89
- var curentProperties = await computeSystem . GetComputeSystemPropertiesAsync ( string . Empty ) ;
90
- return GetComputeSystemCardProperties ( curentProperties , packageFullName ) ;
89
+ var currentProperties = await computeSystem . GetComputeSystemPropertiesAsync ( string . Empty ) ;
90
+ return GetComputeSystemCardProperties ( currentProperties , packageFullName ) ;
91
91
}
92
92
catch ( Exception ex )
93
93
{
@@ -131,7 +131,7 @@ public static EnvironmentsCallToActionData UpdateCallToActionText(int providerCo
131
131
}
132
132
133
133
/// <summary>
134
- /// Safely remove all items from an observable collection.
134
+ /// Safely removes all items from an observable collection and replaces them with new items .
135
135
/// </summary>
136
136
/// <remarks>
137
137
/// There can be random COM exceptions due to using the "Clear()" method in an observable collection. This method
@@ -140,19 +140,32 @@ public static EnvironmentsCallToActionData UpdateCallToActionText(int providerCo
140
140
/// this method is used to remove all items individually from the end of the collection to the beginning of the collection.
141
141
/// </remarks>
142
142
/// <typeparam name="T">Type of objects that the collection contains</typeparam>
143
- /// <param name="collection">An observable collection that contains zero to N elements</param>
144
- public static void RemoveAllItems < T > ( ObservableCollection < T > collection )
143
+ /// <param name="collectionToUpdate">An observable collection that contains zero to N elements that will have its contents replaced</param>
144
+ /// <param name="listWithUpdates">A list that contains zero to N elements whose elements will be added to collectionToUpdate</param>
145
+ /// <returns>
146
+ /// True only if we successfully replaced all items in the collection. False otherwise.
147
+ /// </returns>
148
+ public static bool RemoveAllItemsAndReplace < T > ( ObservableCollection < T > collectionToUpdate , List < T > listWithUpdates )
145
149
{
146
150
try
147
151
{
148
- for ( var i = collection . Count - 1 ; i >= 0 ; i -- )
152
+ for ( var i = collectionToUpdate . Count - 1 ; i >= 0 ; i -- )
149
153
{
150
- collection . RemoveAt ( i ) ;
154
+ collectionToUpdate . RemoveAt ( i ) ;
151
155
}
156
+
157
+ for ( var i = 0 ; i < listWithUpdates . Count ; i ++ )
158
+ {
159
+ collectionToUpdate . Add ( listWithUpdates [ i ] ) ;
160
+ }
161
+
162
+ return true ;
152
163
}
153
164
catch ( Exception ex )
154
165
{
155
166
_log . Error ( ex , "Unable to remove items from the collection" ) ;
156
167
}
168
+
169
+ return false ;
157
170
}
158
171
}
0 commit comments