예제 #1
0
 protected MemberNodeBase(
     NamespaceNode parent,
     IOldToNewTupleMap <MemberDefinitionMetadataBase> map,
     IDecompilationResults oldDecompileResult,
     IDecompilationResults newDecompileResult)
     : base(parent, parent.Namespace, map.GetFirstNotNullItem().GetName())
 {
     Map = map;
     OldDecompileResult = oldDecompileResult;
     NewDecompileResult = newDecompileResult;
 }
예제 #2
0
 public TypeNode(
     NamespaceNode parent,
     IOldToNewTupleMap <TypeMetadata> map,
     IReadOnlyList <MemberNodeBase> members,
     IDecompilationResults oldDecompileResult,
     IDecompilationResults newDecompileResult)
     : base(parent, map, oldDecompileResult, newDecompileResult)
 {
     Parent  = parent;
     Map     = map;
     Members = members;
 }
예제 #3
0
        public static TypeNode Create(NamespaceNode parent, IOldToNewTupleMap <TypeMetadata> map)
        {
            var oldTypeMetadata = map.OldType;
            var newTypeMetadata = map.NewType;

            IDecompilationResults oldResult = null;
            IDecompilationResults newResult = null;

            IDecompilationResults result;

            if (oldTypeMetadata != null &&
                GlobalDecompilationResultsRepository.Instance.TryGetDecompilationResult(
                    oldTypeMetadata.AssemblyPath,
                    oldTypeMetadata.Module.TokenId,
                    oldTypeMetadata.TokenId,
                    out result))
            {
                oldResult = result;
            }

            if (newTypeMetadata != null &&
                GlobalDecompilationResultsRepository.Instance.TryGetDecompilationResult(
                    newTypeMetadata.AssemblyPath,
                    newTypeMetadata.Module.TokenId,
                    newTypeMetadata.TokenId,
                    out result))
            {
                newResult = result;
            }

            var typeNode = new TypeNode(parent, map, new MemberNodeBase[0], oldResult, newResult);

            var memberManager = new MemberMergeManager(map);
            var members       = memberManager.GetMergedCollection().Select <IOldToNewTupleMap <MemberDefinitionMetadataBase>, MemberNodeBase> (
                e =>
            {
                if (e.GetFirstNotNullItem().MemberType == MemberType.Type)
                {
                    return(NestedTypeNode.Create(
                               typeNode,
                               new OldToNewTupleMap <TypeMetadata> ((TypeMetadata)e.OldType, (TypeMetadata)e.NewType)));
                }
                return(new MemberNode(
                           typeNode,
                           new OldToNewTupleMap <MemberMetadata> ((MemberMetadata)e.OldType, (MemberMetadata)e.NewType)));
            }).ToArray();

            typeNode.Members = members;


            return(typeNode);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }