Exemplo n.º 1
0
        /// <returns>返回是否添加了新元素到列表</returns>
        public bool AddBookmarkItem(ref BookmarkItem item, int position = 0, bool isBunchAdd = false)
        {
            string url = item.href.Trim();

            if (bookmarkItemPool.ContainsKey(url))
            {   //更新原链接元素
                var oldItem = bookmarkItemPool[url];
                oldItem.description = item.description;
                oldItem.hash        = item.hash;
                oldItem.isUnReaded  = item.isUnReaded;
                oldItem.isStar      = item.isStar;
                if (!String.IsNullOrWhiteSpace(item.cacheHtml))
                {
                    oldItem.cacheHtml = item.cacheHtml;
                }

                item.Dispose();
                item = oldItem;
            }
            else
            {
                bookmarkItemPool.Add(url, item);
                item.PropertyChanged += App.pocketApi.BookmarkItem_PropertyChanged;
                item.PropertyChanged += App.localFileCache.BookmarkItem_PropertyChanged;
                SaveLinkItemRecord(item);
            }
            return(UpdateIndex(item, position, "", isBunchAdd));
        }
Exemplo n.º 2
0
        public BookmarkItem PocketItem2BookmarkItem(PocketItem item, bool?isUnReaded = null, bool?isStar = null)
        {
            BookmarkItem newItem = new BookmarkItem(
                String.IsNullOrEmpty(item.resolved_url) ? item.given_url : item.resolved_url,
                String.IsNullOrEmpty(item.given_title) ? item.resolved_title : item.given_title,
                item.item_id,
                (isUnReaded == null) ? (item.status == "0") : (isUnReaded == true),
                (isStar == null) ? (item.favorite == "1") : (isStar == true)
                );

            if (String.IsNullOrEmpty(newItem.href))
            {
                newItem.Dispose();
                return(null);
            }
            return(newItem);
        }