public void Connect(Page page1, Page page2) { var root1 = page1.FindRoot(); var root2 = page2.FindRoot(); if (root1 == root2) return; if (root1.Children.Count < root2.Children.Count) SetRoot(root1, root2); else SetRoot(root2, root1); }
public Page CreateOrGet(string language, string title) { title = title.Replace('_', ' '); if (!m_pages.ContainsKey(language)) m_pages[language] = new Dictionary<string, Page>(); var languagePages = m_pages[language]; if (!languagePages.ContainsKey(title)) { var page = new Page(language, title); languagePages[title] = page; m_roots.Add(page); } return languagePages[title]; }
void SetRoot(Page oldRoot, Page newRoot) { oldRoot.Parent = newRoot; newRoot.Children.AddRange(oldRoot.Children); newRoot.Children.Add(oldRoot); oldRoot.Children = null; m_roots.Remove(oldRoot); }