public static NamespaceNode Create( ModuleNode parent, string name, IReadOnlyList <IOldToNewTupleMap <TypeMetadata> > typeMaps) { var namespaceNode = new NamespaceNode(parent, name, new TypeNode[0]); var typeNodes = typeMaps .Select(e => TypeNode.Create(namespaceNode, e)) .ToArray(); namespaceNode.Types = typeNodes; return(namespaceNode); }
public static ModuleNode CreateFromModuleMap(AssemblyNode parent, IOldToNewTupleMap <ModuleMetadata> moduleMap) { var module = new ModuleNode(parent, moduleMap, new NamespaceNode[0]); var types = new TypesMergeManager(moduleMap) .GetMergedCollection() .ToList(); var namespaces = types.GroupBy(e => e.GetFirstNotNullItem().GetNamespace()) .OrderBy(e => e.Key) .Select(e => NamespaceNode.Create(module, e.Key, e.ToArray())) .ToArray(); module.Namespaces = namespaces; return(module); }
public static AssemblyNode Create(IOldToNewTupleMap <string> assemblyMap, IOldToNewTupleMap <GeneratedProjectOutputInfo> generationProjectInfoMap) { var assemblyNode = new AssemblyNode(assemblyMap, new ModuleNode[0], new ResourceNode[0]); var moduleMergeManager = new ModuleManager(assemblyMap); var modulesNodes = moduleMergeManager.GetMergedCollection() .Select(tuple => ModuleNode.CreateFromModuleMap(assemblyNode, tuple)) .ToArray(); assemblyNode.Modules = modulesNodes; ICollection <string> oldResources = new Collection <string>(); ICollection <string> newResources = new Collection <string>(); IAssemblyDecompilationResults oldAssemblyResult; IAssemblyDecompilationResults newAssemblyResult; if (GlobalDecompilationResultsRepository.Instance.TryGetAssemblyDecompilationResult(assemblyMap.OldType, out oldAssemblyResult)) { oldResources = oldAssemblyResult.ResourcesFilePaths; } if (GlobalDecompilationResultsRepository.Instance.TryGetAssemblyDecompilationResult(assemblyMap.NewType, out newAssemblyResult)) { newResources = newAssemblyResult.ResourcesFilePaths; } var resourceMergeManager = new ResourceMergeManager( new OldToNewTupleMap <ICollection <string> > (oldResources, newResources), (a, b) => string.Compare(generationProjectInfoMap.OldType.GetRelativePath(a), generationProjectInfoMap.OldType.GetRelativePath(b), true), (a, b) => string.Compare(generationProjectInfoMap.NewType.GetRelativePath(a), generationProjectInfoMap.NewType.GetRelativePath(b), true), (a, b) => ResourceNameComparer(generationProjectInfoMap, a, b)); var resourceNodes = resourceMergeManager.GetMergedCollection() .Select(e => new ResourceNode(assemblyNode, e)) .ToArray(); assemblyNode.Resources = resourceNodes; return(assemblyNode); }
public NamespaceNode(ModuleNode parent, string name, IReadOnlyList <TypeNode> types) : base(parent, name, "") { Parent = parent; Types = types; }