Example #1
0
        /// <summary>
        /// Determines whether this container contains the same definitions as the given one.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns>True whether this container contains the same definitions as the given one.</returns>
        internal bool DataEquals(DeclarationContainer <T> other)
        {
            HashSet <QualifiedName> names = new HashSet <QualifiedName>();

            HashSetTools.AddAll(names, this.declarations.Keys);
            HashSetTools.AddAll(names, other.declarations.Keys);

            foreach (var name in names)
            {
                HashSet <T> otherDecl, thisDecl;
                if (!other.declarations.TryGetValue(name, out otherDecl))
                {
                    return(false);
                }

                if (!this.declarations.TryGetValue(name, out thisDecl))
                {
                    return(false);
                }

                if (!HashSetTools.EqualsSet(thisDecl, otherDecl))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeclarationContainer{T}"/> class and copy data from the givenb one.
 /// </summary>
 /// <param name="container">The container.</param>
 public DeclarationContainer(DeclarationContainer <T> container)
 {
     declarations = new Dictionary <QualifiedName, HashSet <T> >();
     foreach (var decl in container.declarations)
     {
         declarations[decl.Key] = new HashSet <T>(decl.Value);
     }
 }
Example #3
0
 /// <summary>
 /// Merges single source declaration container with the target.
 /// Adds all delcarations from source container to the target.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 private void mergeDeclarations <T>(DeclarationContainer <T> target, DeclarationContainer <T> source)
 {
     foreach (var name in source.GetNames())
     {
         foreach (var decl in source.GetValue(name))
         {
             target.Add(name, decl);
         }
     }
 }