// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset { using System; using System.Collections.ObjectModel; /// /// A case-insensitive collection of unique objects. /// internal sealed class ProvidesDependencyCollection : KeyedCollection { /// /// Creates a case-insensitive collection of unique objects. /// internal ProvidesDependencyCollection() : base(StringComparer.InvariantCultureIgnoreCase) { } /// /// Adds the to the collection if it doesn't already exist. /// /// The to add to the collection. /// True if the was added to the collection; otherwise, false. /// The parameter is null. internal bool Merge(ProvidesDependency dependency) { if (null == dependency) { throw new ArgumentNullException("dependency"); } // If the dependency key is already in the collection, verify equality for a subset of properties. if (this.Contains(dependency.Key)) { ProvidesDependency current = this[dependency.Key]; if (!current.Equals(dependency)) { return false; } } base.Add(dependency); return true; } /// /// Gets the for the . /// /// The dependency to index. /// The parameter is null. /// The for the . protected override string GetKeyForItem(ProvidesDependency dependency) { if (null == dependency) { throw new ArgumentNullException("dependency"); } return dependency.Key; } } }