/// <summary> /// Generates the document map based on the <see cref="CurrentFiles"/>. /// </summary> public virtual DocumentMap GenerateMap() { EntryCreator.Reset(); DocumentMap map = this.UseObservableCollection ? new ObservableDocumentMap() : new DocumentMap(); int fileCounter = 1; // For each of the documentedfiles generate the document map and add // it to the parent node of the document map for (int i = 0; i < this.CurrentFiles.Count; i++) { if (!this.CurrentFiles[i].IsCompiled) { continue; } Entry assemblyEntry = this.GenerateDocumentForAssembly(map, this.CurrentFiles[i], ref fileCounter); if (assemblyEntry.Children.Count > 0) { map.Add(assemblyEntry); } } map.Sort(); map.NumberOfEntries = this.EntryCreator.Created; return(map); }
/// <summary> /// Generates a document map grouping related namespaces. /// </summary> public override DocumentMap GenerateMap() { EntryCreator.Reset(); DocumentMap map = UseObservableCollection ? new ObservableDocumentMap() : new DocumentMap(); int fileCounter = 1; // For each of the documentedfiles generate the document map and add // it to the parent node of the document map for (int i = 0; i < CurrentFiles.Count; i++) { if (!CurrentFiles[i].IsCompiled) { continue; } GenerateDocumentForAssembly(map, CurrentFiles[i], ref fileCounter); } map.Sort(); bool dontGroupNamespaces = true; List <string> counter = new List <string>(); List <Entry> namespaceContainers = new List <Entry>(); if (map.Count > 10) { // calculate the best level to create groups from or if there is no best place dontGroupNamespaces = false; float parentPercentage = 0, currentPercentage = 0; int currentLevel = 0; do { counter.Clear(); for (int dmI = 0; dmI < map.Count; dmI++) { string[] parts = map[dmI].Name.Split('.'); string currentNamespace = parts.Length > currentLevel?string.Join(".", parts, 0, currentLevel + 1) : string.Join(".", parts); if (!counter.Contains(currentNamespace)) { counter.Add(currentNamespace); } } currentPercentage = counter.Count / ((float)map.Count); if (parentPercentage < 0.1 && currentPercentage > 0.65 && currentLevel > 0) { dontGroupNamespaces = true; break; } currentLevel++; parentPercentage = counter.Count / ((float)map.Count); }while (counter.Count / ((float)map.Count) < 0.1306); } if (!dontGroupNamespaces) { // create all the top level groupings int id = 0; for (int cI = 0; cI < counter.Count; cI++) { Entry namespaceContainer = EntryCreator.Create(EntryTypes.NamespaceContainer, counter[cI], null); namespaceContainer.Key = id++; if (string.IsNullOrEmpty(counter[cI])) { // this is the no name namespace namespaceContainer.SubKey = "No Namespace"; } else { namespaceContainer.SubKey = counter[cI] + "Namespaces"; } namespaceContainers.Add(namespaceContainer); } // add all the namespaces to the groupings for (int namespaceI = 0; namespaceI < map.Count; namespaceI++) { for (int containersI = namespaceContainers.Count; containersI > 0; containersI--) { if (map[namespaceI].Name.Contains(namespaceContainers[containersI - 1].Name)) { map[namespaceI].Parent = namespaceContainers[containersI - 1]; namespaceContainers[containersI - 1].Children.Add(map[namespaceI]); break; } } } } if (namespaceContainers.Count > 1) { map.Clear(); for (int i = 0; i < namespaceContainers.Count; i++) { namespaceContainers[i].Name += " Namespaces"; map.Add(namespaceContainers[i]); } } map.NumberOfEntries = EntryCreator.Created; return(map); }