@@ -234,87 +234,98 @@ public bool GroupByLocation
234
234
}
235
235
}
236
236
237
- public bool _filterInspectionsByHint ;
237
+ private List < CodeInspectionSeverity > _filterCriteria = new List < CodeInspectionSeverity > ( ) ;
238
+
238
239
public bool FilterInspectionsByHint
239
240
{
240
- get => _filterInspectionsByHint ;
241
+ get => _filterCriteria . Contains ( CodeInspectionSeverity . Hint ) ;
241
242
set
242
243
{
243
- if ( _filterInspectionsByHint == value ) { return ; }
244
+ if ( FilterInspectionsByHint == value ) { return ; }
245
+
246
+ if ( value )
247
+ {
248
+ _filterCriteria . Add ( CodeInspectionSeverity . Hint ) ;
249
+ }
250
+ else
251
+ {
252
+ _filterCriteria . Remove ( CodeInspectionSeverity . Hint ) ;
253
+ }
244
254
245
- FilterResults ( filterByHint : value ) ;
255
+ FilterResults ( _filterCriteria ) ;
246
256
OnPropertyChanged ( ) ;
247
257
}
248
258
}
249
259
250
- private bool _filterInspectionsBySuggestion ;
251
260
public bool FilterInspectionsBySuggestion
252
261
{
253
- get => _filterInspectionsBySuggestion ;
262
+ get => _filterCriteria . Contains ( CodeInspectionSeverity . Suggestion ) ;
254
263
set
255
264
{
256
- if ( _filterInspectionsBySuggestion == value ) { return ; }
265
+ if ( FilterInspectionsBySuggestion == value ) { return ; }
257
266
258
- FilterResults ( filterBySuggestion : value ) ;
267
+ if ( value )
268
+ {
269
+ _filterCriteria . Add ( CodeInspectionSeverity . Suggestion ) ;
270
+ }
271
+ else
272
+ {
273
+ _filterCriteria . Remove ( CodeInspectionSeverity . Suggestion ) ;
274
+ }
275
+
276
+ FilterResults ( _filterCriteria ) ;
259
277
OnPropertyChanged ( ) ;
260
278
}
261
279
}
262
280
263
- private bool _filterInspectionsByWarning ;
264
281
public bool FilterInspectionsByWarning
265
282
{
266
- get => _filterInspectionsByWarning ;
283
+ get => _filterCriteria . Contains ( CodeInspectionSeverity . Warning ) ;
267
284
set
268
285
{
269
- if ( _filterInspectionsByWarning == value ) { return ; }
286
+ if ( FilterInspectionsByWarning == value ) { return ; }
287
+
288
+ if ( value )
289
+ {
290
+ _filterCriteria . Add ( CodeInspectionSeverity . Warning ) ;
291
+ }
292
+ else
293
+ {
294
+ _filterCriteria . Remove ( CodeInspectionSeverity . Warning ) ;
295
+ }
270
296
271
- FilterResults ( filterByWarning : value ) ;
297
+ FilterResults ( _filterCriteria ) ;
272
298
OnPropertyChanged ( ) ;
273
299
}
274
300
}
275
301
276
- private bool _filterInspectionsByError ;
277
302
public bool FilterInspectionsByError
278
303
{
279
- get => _filterInspectionsByError ;
304
+ get => _filterCriteria . Contains ( CodeInspectionSeverity . Error ) ;
280
305
set
281
306
{
282
- if ( _filterInspectionsByError == value ) { return ; }
307
+ if ( FilterInspectionsByError == value ) { return ; }
283
308
284
- FilterResults ( filterByError : value ) ;
309
+ if ( value )
310
+ {
311
+ _filterCriteria . Add ( CodeInspectionSeverity . Error ) ;
312
+ }
313
+ else
314
+ {
315
+ _filterCriteria . Remove ( CodeInspectionSeverity . Error ) ;
316
+ }
317
+
318
+ FilterResults ( _filterCriteria ) ;
285
319
OnPropertyChanged ( ) ;
286
320
}
287
321
}
288
322
289
- public void FilterResults ( bool filterByHint = false , bool filterBySuggestion = false , bool filterByWarning = false , bool filterByError = false )
323
+ public void FilterResults ( IEnumerable < CodeInspectionSeverity > inspections )
290
324
{
291
- _filterInspectionsByHint = filterByHint ;
292
- _filterInspectionsBySuggestion = filterBySuggestion ;
293
- _filterInspectionsByWarning = filterByWarning ;
294
- _filterInspectionsByError = filterByError ;
295
-
296
- if ( _filterInspectionsByHint )
297
- {
298
- Results = new ObservableCollection < IInspectionResult > (
299
- _resultsAll . Where ( o => o . Inspection . Severity == CodeInspectionSeverity . Hint )
300
- . ToList ( ) ) ;
301
- }
302
- else if ( _filterInspectionsBySuggestion )
303
- {
304
- Results = new ObservableCollection < IInspectionResult > (
305
- _resultsAll . Where ( o => o . Inspection . Severity == CodeInspectionSeverity . Suggestion )
306
- . ToList ( ) ) ;
307
- }
308
- else if ( _filterInspectionsByWarning )
309
- {
310
- Results = new ObservableCollection < IInspectionResult > (
311
- _resultsAll . Where ( o => o . Inspection . Severity == CodeInspectionSeverity . Warning )
312
- . ToList ( ) ) ;
313
- }
314
- else if ( _filterInspectionsByError )
325
+ if ( _filterCriteria . Any ( ) )
315
326
{
316
327
Results = new ObservableCollection < IInspectionResult > (
317
- _resultsAll . Where ( o => o . Inspection . Severity == CodeInspectionSeverity . Error )
328
+ _resultsAll . Where ( o => _filterCriteria . Contains ( o . Inspection . Severity ) )
318
329
. ToList ( ) ) ;
319
330
}
320
331
else
0 commit comments