public static NavigationTree CreateNavigationTree(UserContext userContext, NavigationNodeGroupSection groupSection) { List <FolderList> folderLists = new List <FolderList>(); folderLists.Add(new FolderList(userContext, userContext.MailboxSession, new string[] { NavigationNode.GetFolderClass(groupSection) }, 10000, false, null, FolderList.FolderTreeQueryProperties)); if (userContext.ArchiveAccessed) { userContext.TryLoopArchiveMailboxes(delegate(MailboxSession archiveSession) { folderLists.Add(new FolderList(userContext, archiveSession, new string[] { NavigationNode.GetFolderClass(groupSection) }, 10000, false, null, FolderList.FolderTreeQueryProperties)); }); } NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(userContext, userContext.MailboxSession, groupSection); return(NavigationTree.CreateNavigationTreeByFolderLists(userContext, folderLists.ToArray(), new NavigationNodeCollection[] { navigationNodeCollection })[0]); }
public static NavigationTree[] CreateFavoriteAndNavigationTrees(UserContext userContext, params NavigationNodeGroupSection[] groupSections) { bool includeSearchFolder = false; NavigationTree[] array = new NavigationTree[groupSections.Length]; NavigationNodeCollection navigationCollection = null; for (int i = 0; i < groupSections.Length; i++) { if (groupSections[i] == NavigationNodeGroupSection.First) { includeSearchFolder = true; } } NavigationTree.NormalAndSearchFolderList item; NavigationTree.NormalAndSearchFolderList[] array2; NavigationTree.CreateNormalAndSearchFolderLists(userContext, false, includeSearchFolder, out item, out array2); NavigationNodeCollection[] array3 = NavigationNodeCollection.TryCreateNavigationNodeCollections(userContext, userContext.MailboxSession, groupSections); List <NavigationNodeCollection> list = new List <NavigationNodeCollection>(); for (int j = 0; j < array3.Length; j++) { NavigationNodeGroupSection navigationNodeGroupSection = array3[j].GroupSection; if (navigationNodeGroupSection != NavigationNodeGroupSection.First) { if ((navigationNodeGroupSection == NavigationNodeGroupSection.Calendar && userContext.IsFeatureEnabled(Feature.Calendar)) || (navigationNodeGroupSection == NavigationNodeGroupSection.Contacts && userContext.IsFeatureEnabled(Feature.Contacts)) || (navigationNodeGroupSection == NavigationNodeGroupSection.Tasks && userContext.IsFeatureEnabled(Feature.Tasks))) { list.Add(array3[j]); } } else { navigationCollection = array3[j]; } } List <NavigationTree.NormalAndSearchFolderList> list2 = new List <NavigationTree.NormalAndSearchFolderList>(1 + array2.Length); list2.Add(item); list2.AddRange(array2); List <FolderList> list3 = new List <FolderList>(); foreach (NavigationTree.NormalAndSearchFolderList normalAndSearchFolderList in list2) { list3.Add(normalAndSearchFolderList.DeepHierarchyFolderList); } NavigationTree[] array4 = NavigationTree.CreateNavigationTreeByFolderLists(userContext, list3.ToArray(), list.ToArray()); for (int k = 0; k < groupSections.Length; k++) { if (groupSections[k] == NavigationNodeGroupSection.First) { array[k] = NavigationTree.CreateFavoriteTreeByFolderLists(userContext, navigationCollection, list2.ToArray()); } else { array[k] = null; for (int l = 0; l < array4.Length; l++) { if (array4[l].groupSection == groupSections[k]) { array[k] = array4[l]; break; } } } } return(array); }