private bool IsSelected([NotNull] IMitigation item, string filter, MitigationListFilter filterSpecial) { bool result; if (string.IsNullOrWhiteSpace(filter)) { result = true; } else { result = (!string.IsNullOrWhiteSpace(item.Name) && item.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) || (!string.IsNullOrWhiteSpace(item.Description) && item.Description.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0); if (!result && (item.Properties?.Any() ?? false)) { var properties = item.Properties.ToArray(); foreach (var property in properties) { var stringValue = property.StringValue; if ((!string.IsNullOrWhiteSpace(stringValue) && stringValue.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)) { result = true; break; } } } } if (result) { switch (filterSpecial) { case MitigationListFilter.NoThreatTypes: result = !(_model.ThreatTypes?.Any(x => x.Mitigations?.Any(y => y.MitigationId == item.Id) ?? false) ?? false); break; case MitigationListFilter.NoThreatEvents: result = !((_model.ThreatEvents?.Any(x => x.Mitigations?.Any(y => y.MitigationId == item.Id) ?? false) ?? false) || (_model.Entities?.Any(x => x.ThreatEvents?.Any(y => y.Mitigations?.Any(z => z.MitigationId == item.Id) ?? false) ?? false) ?? false) || (_model.DataFlows?.Any(x => x.ThreatEvents?.Any(y => y.Mitigations?.Any(z => z.MitigationId == item.Id) ?? false) ?? false) ?? false)); break; } } return(result); }
private bool IsSelected([NotNull] IMitigation item, IEnumerable <IThreatEventMitigation> mitigations, string filter, MitigationListFilter filterSpecial) { bool result; if (string.IsNullOrWhiteSpace(filter)) { result = true; } else { result = (!string.IsNullOrWhiteSpace(item.Name) && item.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0) || (!string.IsNullOrWhiteSpace(item.Description) && item.Description.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0); if (!result && (item.Properties?.Any() ?? false)) { var properties = item.Properties.ToArray(); foreach (var property in properties) { var stringValue = property.StringValue; if ((!string.IsNullOrWhiteSpace(stringValue) && stringValue.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)) { result = true; break; } } } } if (result) { switch (filterSpecial) { case MitigationListFilter.UndefinedMitigations: result = mitigations?.Any(x => x.Status == MitigationStatus.Undefined) ?? false; break; } } return(result); }