当前位置: 首页>>代码示例>>C#>>正文


C# Module.Clone方法代码示例

本文整理汇总了C#中Module.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Module.Clone方法的具体用法?C# Module.Clone怎么用?C# Module.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Module的用法示例。


在下文中一共展示了Module.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitModule

    public virtual Differences VisitModule(Module module1, Module module2){
      Differences differences = new Differences(module1, module2);
      if (module1 == null || module2 == null){
        if (module1 != module2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      Module changes = (Module)module2.Clone();
      Module deletions = (Module)module2.Clone();
      Module insertions = (Module)module2.Clone();

      this.OriginalModule = module1;
      this.NewModule = module2;

      AssemblyReferenceList arChanges, arDeletions, arInsertions;
      Differences diff = this.VisitAssemblyReferenceList(module1.AssemblyReferences, module2.AssemblyReferences, out arChanges, out arDeletions, out arInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.AssemblyReferences = arChanges;
      deletions.AssemblyReferences = arDeletions;
      insertions.AssemblyReferences = arInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      AttributeList attrChanges, attrDeletions, attrInsertions;
      diff = this.VisitAttributeList(module1.Attributes, module2.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;

      if (module1.HashAlgorithm == module2.HashAlgorithm) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      if (module1.Kind == module2.Kind) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      ModuleReferenceList mrChanges, mrDeletions, mrInsertions;
      diff = this.VisitModuleReferenceList(module1.ModuleReferences, module2.ModuleReferences, out mrChanges, out mrDeletions, out mrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.ModuleReferences = mrChanges;
      deletions.ModuleReferences = mrDeletions;
      insertions.ModuleReferences = mrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (module1.Name == module2.Name) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      if (module1.PEKind == module2.PEKind) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      SecurityAttributeList secChanges, secDeletions, secInsertions;
      diff = this.VisitSecurityAttributeList(module1.SecurityAttributes, module2.SecurityAttributes, out secChanges, out secDeletions, out secInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.SecurityAttributes = secChanges;
      deletions.SecurityAttributes = secDeletions;
      insertions.SecurityAttributes = secInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (module1.TargetRuntimeVersion == module2.TargetRuntimeVersion) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      if (module1.TrackDebugData == module2.TrackDebugData) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      TypeNodeList typeChanges, typeDeletions, typeInsertions;
      diff = this.VisitTypeNodeList(module1.Types, module2.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;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:78,代码来源:Comparer.cs


注:本文中的Module.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。