From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- .../Bind/ProvidesDependencyCollection.cs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/WixToolset.Core.Burn/Bind/ProvidesDependencyCollection.cs (limited to 'src/WixToolset.Core.Burn/Bind/ProvidesDependencyCollection.cs') diff --git a/src/WixToolset.Core.Burn/Bind/ProvidesDependencyCollection.cs b/src/WixToolset.Core.Burn/Bind/ProvidesDependencyCollection.cs new file mode 100644 index 00000000..668b81d3 --- /dev/null +++ b/src/WixToolset.Core.Burn/Bind/ProvidesDependencyCollection.cs @@ -0,0 +1,64 @@ +// 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.Core.Burn +{ + 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; + } + } +} -- cgit v1.2.3-55-g6feb