Microsoft.PackageManagement.NuGetProvider.NuGetRequest.FilterOnName C# (CSharp) Method

FilterOnName() private method

private FilterOnName ( IEnumerable pkgs, string searchTerm, bool useWildCard ) : IEnumerable
pkgs IEnumerable
searchTerm string
useWildCard bool
return IEnumerable
        private IEnumerable<IPackage> FilterOnName(IEnumerable<IPackage> pkgs, string searchTerm, bool useWildCard)
        {
            if (useWildCard)
            {
                // Applying the wildcard pattern matching
                const WildcardOptions wildcardOptions = WildcardOptions.CultureInvariant | WildcardOptions.IgnoreCase;
                var wildcardPattern = new WildcardPattern(searchTerm, wildcardOptions);

                return pkgs.Where(p => wildcardPattern.IsMatch(p.Id));

            } else {
                return pkgs.Where(each => each.Id.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) > -1);
            }
        }