예제 #1
0
        private static Bookmark RetriveBookmark(SetRecord record)
        {
            string        name = record.ReadAs <string>("name");
            ChineseChar   ch;
            StringBuilder builder = new StringBuilder(name.Length);

            foreach (char c in name)
            {
                if (ChineseChar.IsValidChar(c))
                {
                    ch = new ChineseChar(c);
                    builder.Append(ch.Pinyins[0]);
                    builder.Remove(builder.Length - 1, 1);
                }
                else
                {
                    builder.Append(c);
                }
            }
            string pinyin = builder.ToString().ToLower();

            return(new Bookmark()
            {
                Name = name,
                Url = record.ReadAs <string>("url"),
                NamePinYin = pinyin
            });
        }
예제 #2
0
        private static BookmarkFolder RetriveFolder(SetRecord record)
        {
            string                name = record.ReadAs <string>("name");
            string                type;
            ListRecord            children  = record["children"] as ListRecord;
            List <Bookmark>       bookmarks = new List <Bookmark>();
            List <BookmarkFolder> folders   = new List <BookmarkFolder>();

            foreach (RecordBase rec in children)
            {
                if (rec is SetRecord set)
                {
                    type = set.ReadAs <string>("type");
                    if (type == "folder")
                    {
                        folders.Add(RetriveFolder(set));
                    }
                    else if (type == "url")
                    {
                        bookmarks.Add(RetriveBookmark(set));
                    }
                }
            }
            return(new BookmarkFolder()
            {
                Name = name,
                Bookmarks = bookmarks,
                Folders = folders
            });
        }