/* Function: FindOrCreateLanguageEntryOf * Finds or creates the language entry associated with the passed ClassString. */ protected MenuEntries.Language FindOrCreateLanguageEntryOf(Symbols.ClassString classString) { var language = EngineInstance.Languages.FromID(classString.LanguageID); var languageEntry = FindLanguageEntry(language); if (languageEntry == null) { languageEntry = CreateLanguageEntry(language); } return(languageEntry); }
/* Function: PageLocation * Creates a new page location for a class page. */ public PageLocation(int classID, Symbols.ClassString classString) { #if DEBUG if (classString != null && classID == 0) { throw new Exception("Can't create a PageLocation from a class string when its ID isn't known."); } if (classID != 0 && classString == null) { throw new Exception("Can't create a PageLocation from a class ID when its string isn't known."); } #endif this.fileID = 0; this.classID = classID; this.classString = classString; }
/* Constructor: Context * Creates a context that includes a class page. */ public Context(HTML.Target target, int classID, Symbols.ClassString classString, Topic topic = null) { #if DEBUG if (classString != null && classID == 0) { throw new Exception("Can't create a Context from a class string when its ID isn't known."); } if (classID != 0 && classString == null) { throw new Exception("Can't create a Context from a class ID when its string isn't known."); } #endif this.target = target; this.page = new PageLocation(classID, classString); this.topic = topic; }
/* Function: AddClass * Adds a class to the menu tree. */ public void AddClass(Symbols.ClassString classString) { #if DEBUG if (isCondensed) { throw new Exception("Cannot add a class to the menu once it's been condensed."); } #endif string[] classSegments = classString.Symbol.SplitSegments(); MenuEntries.Container container; bool ignoreCase; if (classString.Hierarchy == Hierarchy.Class) { MenuEntries.Language languageEntry = FindOrCreateLanguageEntryOf(classString); container = languageEntry; ignoreCase = (languageEntry.WrappedLanguage.CaseSensitive == false); } else if (classString.Hierarchy == Hierarchy.Database) { if (rootDatabaseMenu == null) { rootDatabaseMenu = new MenuEntries.Container(Hierarchy.Database); rootDatabaseMenu.Title = Engine.Locale.Get("NaturalDocs.Engine", "Menu.Database"); } container = rootDatabaseMenu; ignoreCase = true; } else { throw new NotImplementedException(); } // Create the class and find out where it goes. Create new scope containers as necessary. MenuEntries.Class classEntry = new MenuEntries.Class(classString); string scopeSoFar = null; // We only want to walk through the scope levels so we use length - 1 to ignore the last segment, which is the class name. for (int i = 0; i < classSegments.Length - 1; i++) { string classSegment = classSegments[i]; if (scopeSoFar == null) { scopeSoFar = classSegment; } else { scopeSoFar += Symbols.SymbolString.SeparatorChar + classSegment; } MenuEntries.Scope scopeEntry = null; foreach (var member in container.Members) { if (member is MenuEntries.Scope && string.Compare((member as MenuEntries.Scope).WrappedScopeString, scopeSoFar, ignoreCase) == 0) { scopeEntry = (MenuEntries.Scope)member; break; } } if (scopeEntry == null) { scopeEntry = new MenuEntries.Scope(Symbols.SymbolString.FromExportedString(scopeSoFar), classString.Hierarchy); scopeEntry.Parent = container; container.Members.Add(scopeEntry); } container = scopeEntry; } classEntry.Parent = container; container.Members.Add(classEntry); }
// Group: Functions // __________________________________________________________________________ /* Function: Class */ public Class(Symbols.ClassString classString) : base() { this.classString = classString; this.Title = classString.Symbol.LastSegment; }