Esempio n. 1
0
        protected override void LoadChildren()
        {
            ModuleDefinition moduleDefinition = assembly.GetModuleDefinitionAsync().Result;

            if (moduleDefinition == null)
            {
                // if we crashed on loading, then we don't have any children
                return;
            }

            this.Children.Add(new ReferenceFolderTreeNode(moduleDefinition, this));
            if (moduleDefinition.HasResources)
            {
                this.Children.Add(new ResourceListTreeNode(moduleDefinition));
            }
            foreach (NamespaceTreeNode ns in namespaces.Values)
            {
                ns.Children.Clear();
            }
            foreach (TypeDefinition type in moduleDefinition.Types.OrderBy(t => t.FullName, NaturalStringComparer.Instance))
            {
                NamespaceTreeNode ns;
                if (!namespaces.TryGetValue(type.Namespace, out ns))
                {
                    ns = new NamespaceTreeNode(type.Namespace);
                    namespaces[type.Namespace] = ns;
                }
                TypeTreeNode node = new TypeTreeNode(type, this);
                typeDict[type] = node;
                ns.Children.Add(node);
            }
            foreach (NamespaceTreeNode ns in namespaces.Values.OrderBy(n => n.Name, NaturalStringComparer.Instance))
            {
                if (ns.Children.Count > 0)
                {
                    this.Children.Add(ns);
                }
            }
        }