Наследование: MutationNode
Пример #1
0
        public AssemblyNode CreateAssemblyNode(IModuleInfo module,
                                               ICodePartsMatcher matcher)
        {
            var assemblyNode = new AssemblyNode(module.Name);

            assemblyNode.AssemblyPath = module.Module.Location.ToFilePathAbs();
            System.Action <CheckedNode, ICollection <INamedTypeDefinition> > typeNodeCreator = (parent, leafTypes) =>
            {
                foreach (INamedTypeDefinition typeDefinition in leafTypes)
                {
                    // _log.Debug("For types: matching: ");
                    if (matcher.Matches(typeDefinition))
                    {
                        var type = new TypeNode(parent, typeDefinition.Name.Value);
                        foreach (var method in typeDefinition.Methods)
                        {
                            if (matcher.Matches(method))
                            {
                                type.Children.Add(new MethodNode(type, method.Name.Value, method, false));
                            }
                        }
                        parent.Children.Add(type);
                    }
                }
            };
            Func <INamedTypeDefinition, string> namespaceExtractor = typeDef =>
                                                                     TypeHelper.GetDefiningNamespace(typeDef).Name.Value;


            NamespaceGrouper <INamespaceTypeDefinition, CheckedNode> .
            GroupTypes(assemblyNode,
                       namespaceExtractor,
                       (parent, name) => new TypeNamespaceNode(parent, name),
                       typeNodeCreator,
                       module.Module.GetAllTypes().ToList());


            //remove empty amespaces.
            //TODO to refactor...
            List <TypeNamespaceNode> checkedNodes = assemblyNode.Children.OfType <TypeNamespaceNode>().ToList();

            foreach (TypeNamespaceNode node in checkedNodes)
            {
                RemoveFromParentIfEmpty(node);
            }
            return(assemblyNode);
        }
        public AssemblyNode CreateAssemblyNode(IModuleInfo module, 
            ICodePartsMatcher matcher)
        {
            var assemblyNode = new AssemblyNode(module.Name);
            assemblyNode.AssemblyPath = module.Module.Location.ToFilePathAbs();
            System.Action<CheckedNode, ICollection<INamedTypeDefinition>> typeNodeCreator = (parent, leafTypes) =>
            {
                foreach (INamedTypeDefinition typeDefinition in leafTypes)
                {
                   // _log.Debug("For types: matching: ");
                    if (matcher.Matches(typeDefinition))
                    {
                        var type = new TypeNode(parent, typeDefinition.Name.Value);
                        foreach (var method in typeDefinition.Methods)
                        {
                            if (matcher.Matches(method))
                            {
                                type.Children.Add(new MethodNode(type, method.Name.Value, method, false));
                            }
                        }
                        parent.Children.Add(type);
                    }
                }
            };
            Func<INamedTypeDefinition, string> namespaceExtractor = typeDef =>
                TypeHelper.GetDefiningNamespace(typeDef).Name.Value;


            NamespaceGrouper<INamespaceTypeDefinition, CheckedNode>.
                GroupTypes(assemblyNode,
                    namespaceExtractor,
                    (parent, name) => new TypeNamespaceNode(parent, name),
                    typeNodeCreator,
                        module.Module.GetAllTypes().ToList());


            //remove empty amespaces. 
            //TODO to refactor...
            List<TypeNamespaceNode> checkedNodes = assemblyNode.Children.OfType<TypeNamespaceNode>().ToList();
            foreach (TypeNamespaceNode node in checkedNodes)
            {
                RemoveFromParentIfEmpty(node);
            }
            return assemblyNode;
        }