예제 #1
0
        public static void Copy(Catalogue toCatalogue, Namespace ns, ReadOnlyOption readOnlyOption, bool isReferenced, bool iterate)
        {
            INamespaceParent parent = toCatalogue.EnsureNamespaceParent(ns.Parent.FullName);

            // Clone the source namespace, so that CopyElement can modify it by calling PushAllEnabledEventsToChildren().

            CopyElement(parent, ns.Clone(ns.Parent, ns.Name), iterate);
        }
예제 #2
0
        /// <summary>
        /// Implement the ICloneable interface
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            WMIQuery clone = new WMIQuery();

            clone.Name      = Name.Clone() as string;
            clone.Namespace = Namespace.Clone() as string;
            clone.Query     = Query.Clone() as string;

            return(clone);
        }
        public void Namespace()
        {
            Namespace inter = new Namespace(controller);

            inter.Name = "File";
            inter.AddChild(new Class(controller, "Class1"));

            Namespace clone = (Namespace)inter.Clone();

            clone.Controller = new CSharpController();

            Assert.That(inter.IsTheSame(clone, ComparisonDepth.Outer), Is.True);
            Assert.That(clone.WalkChildren(), Has.Count(0));
            Assert.That(inter.IsTheSame(clone, ComparisonDepth.Complete), Is.False);
        }
예제 #4
0
    public virtual Differences VisitNamespace(Namespace nspace1, Namespace nspace2){
      Differences differences = new Differences(nspace1, nspace2);
      if (nspace1 == null || nspace2 == null){
        if (nspace1 != nspace2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Namespace changes = (Namespace)nspace2.Clone();
      Namespace deletions = (Namespace)nspace2.Clone();
      Namespace insertions = (Namespace)nspace2.Clone();

      AliasDefinitionList aliasChanges, aliasDeletions, aliasInsertions;
      Differences diff = this.VisitAliasDefinitionList(nspace1.AliasDefinitions, nspace2.AliasDefinitions, out aliasChanges, out aliasDeletions, out aliasInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.AliasDefinitions = aliasChanges;
      deletions.AliasDefinitions = aliasDeletions;
      insertions.AliasDefinitions = aliasInsertions;
      //check not null
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      AttributeList attrChanges, attrDeletions, attrInsertions;
      diff = this.VisitAttributeList(nspace1.Attributes, nspace2.Attributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Attributes = attrChanges;
      deletions.Attributes = attrDeletions;
      insertions.Attributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitIdentifier(nspace1.Name, nspace2.Name);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Name = diff.Changes as Identifier;
      deletions.Name = diff.Deletions as Identifier;
      insertions.Name = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.Name && diff.Deletions == deletions.Name && diff.Insertions == insertions.Name);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      NamespaceList nsChanges, nsDeletions, nsInsertions;
      diff = this.VisitNamespaceList(nspace1.NestedNamespaces, nspace2.NestedNamespaces, out nsChanges, out nsDeletions, out nsInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.NestedNamespaces = nsChanges;
      deletions.NestedNamespaces = nsDeletions;
      insertions.NestedNamespaces = nsInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitIdentifier(nspace1.URI, nspace2.URI);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.URI = diff.Changes as Identifier;
      deletions.URI = diff.Deletions as Identifier;
      insertions.URI = diff.Insertions as Identifier;
      Debug.Assert(diff.Changes == changes.URI && diff.Deletions == deletions.URI && diff.Insertions == insertions.URI);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      UsedNamespaceList usedChanges, usedDeletions, usedInsertions;
      diff = this.VisitUsedNamespaceList(nspace1.UsedNamespaces, nspace2.UsedNamespaces, out usedChanges, out usedDeletions, out usedInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.UsedNamespaces = usedChanges;
      deletions.UsedNamespaces = usedDeletions;
      insertions.UsedNamespaces = usedInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      TypeNodeList typeChanges, typeDeletions, typeInsertions;
      diff = this.VisitTypeNodeList(nspace1.Types, nspace2.Types, out typeChanges, out typeDeletions, out typeInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Types = typeChanges;
      deletions.Types = typeDeletions;
      insertions.Types = typeInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
예제 #5
0
 public override Namespace VisitNamespace(Namespace nspace)
 {
     if (nspace == null) return null;
     return base.VisitNamespace((Namespace)nspace.Clone());
 }