public static bool ContainsAll()

in src/VSSetup.PowerShell/PowerShell/Extensions.cs [33:53]


        public static bool ContainsAll<T, TKey>(this IEnumerable<T> source, Func<T, TKey> selector, IEnumerable<TKey> keys, IEqualityComparer<TKey> comparer = null)
        {
            Validate.NotNull(source, nameof(source));
            Validate.NotNull(selector, nameof(selector));
            Validate.NotNull(keys, nameof(keys));

            comparer = comparer ?? EqualityComparer<TKey>.Default;

            var e = source.Select(selector);
            var items = new HashSet<TKey>(e, comparer);

            foreach (var key in keys)
            {
                if (!items.Contains(key))
                {
                    return false;
                }
            }

            return true;
        }