| File: Utility\CollectionsUtility.cs | Web Access |
| Project: src\nuget-client\src\NuGet.Core\NuGet.PackageManagement\NuGet.PackageManagement.csproj (NuGet.PackageManagement) |
// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. #nullable disable using System; using System.Collections.Generic; using System.Linq; namespace NuGet.ProjectManagement { public static class CollectionsUtility { public static void AddRange<T>(ICollection<T> collection, IEnumerable<T> items) { foreach (var item in items) { collection.Add(item); } } public static int RemoveAll<T>(ICollection<T> collection, Func<T, bool> match) { IList<T> toRemove = collection.Where(match).ToList(); foreach (var item in toRemove) { collection.Remove(item); } return toRemove.Count; } } }