예제 #1
0
        private TocItem FindItem(int pagenumber)
        {
            DirectoryInfo dataFolder = DataFolder;
            FileInfo      tocDki     = dataFolder.GetFileIgnoreCase(TreeDki);
            FileInfo      tocDka     = dataFolder.GetFileIgnoreCase(TreeDka);
            TocItem       item       = TocUtil.LoadTree(tocDki, tocDka);

            while (item.Pagenumber != pagenumber || item.Pagecount == 0)
            {
                List <TocItem> childrenReverse = item.ChildrenConcrete.AsEnumerable().Reverse().ToList();
                TocItem        child           = childrenReverse.Find(c => c.Pagenumber <= pagenumber);
                if (child == null)
                {
                    break;
                }

                item = child;
            }

            while (item.Pagecount == 0 && item.ParentConcrete != null)
            {
                item = item.ParentConcrete;
            }

            return(item);
        }
예제 #2
0
        public Task <ITocItem> QueryToc(string pattern, IEnumerable <ICategoryItem> categories)
        {
            DirectoryInfo dataFolder = DataFolder;
            FileInfo      treeDki    = dataFolder.GetFileIgnoreCase(TreeDki);
            FileInfo      treeDka    = dataFolder.GetFileIgnoreCase(TreeDka);
            TocItem       root       = TocUtil.LoadTree(treeDki, treeDka);

            return(Task.FromResult <ITocItem>(root));
        }