private void create_root() { // 1. load assemblies List <AssemblyEntry> entries = GetAssmblies(); List <Assembly> loaded = new List <Assembly>(); foreach (AssemblyEntry ae in entries) { try { if (ae.Enabled) { loaded.Add(Assembly.Load(ae.Name)); } } catch { } } // 2. load classes List <Type> classes = new List <Type>(); foreach (Assembly asm in loaded) { Type [] types = asm.GetTypes(); foreach (Type t in types) { if (!t.IsNotPublic) { if (t.IsClass || t.IsInterface || t.IsEnum) { classes.Add(t); } } } } // 3. create namespace root root = new NamespaceData(""); foreach (Type type in classes) { String name = type.FullName; NamespaceData pos = root.FindNamespaceFromClassName(name); pos.classes.Add(type); } // 4. and sort it! root.Sort(); }
// ------------------------------------------ private NamespaceData FindNamespaceFromClassName(String [] names, int offset, int count) { if (offset >= count) { return(this); } foreach (NamespaceData nd in namespaces) { if (nd.name == names[offset]) { return(nd.FindNamespaceFromClassName(names, offset + 1, count)); } } NamespaceData n2 = new NamespaceData(names[offset]); namespaces.Add(n2); return(n2.FindNamespaceFromClassName(names, offset + 1, count)); }