Esempio n. 1
0
        /* ----------------------------------------------------------------- */
        ///
        /// Update
        ///
        /// <summary>
        /// RSS の内容を更新します。
        /// </summary>
        ///
        /// <param name="dest">更新先オブジェクト</param>
        /// <param name="src">更新内容</param>
        ///
        /// <returns>新着記事数</returns>
        ///
        /* ----------------------------------------------------------------- */
        public static int Update(this RssEntry dest, RssFeed src)
        {
            var threshold = dest.LastChecked;

            dest.LastChecked = src.LastChecked;

            if (src.Error != null)
            {
                dest.LogDebug($"{dest.Uri} ({src.Error.GetType().Name})");
                src.Title = dest.Title;
                return(0);
            }

            var received = src.Items.Shrink(threshold).ToList();

            foreach (var item in received)
            {
                dest.Items.Insert(0, item);
            }

            dest.Description   = src.Description;
            dest.Count         = dest.UnreadItems.Count();
            dest.Link          = src.Link;
            dest.LastPublished = src.LastPublished;

            return(received.Count);
        }
Esempio n. 2
0
 /* ----------------------------------------------------------------- */
 ///
 /// PropertyViewModel
 ///
 /// <summary>
 /// オブジェクトを初期化します。
 /// </summary>
 ///
 /// <param name="entry">RssEntry オブジェクト</param>
 /// <param name="callback">コールバック関数</param>
 ///
 /* ----------------------------------------------------------------- */
 public PropertyViewModel(RssEntry entry, Action <RssEntry> callback) :
     base(new Messenger())
 {
     System.Diagnostics.Debug.Assert(entry != null);
     Entry     = new Bindable <RssEntry>(entry);
     _callback = callback;
 }
Esempio n. 3
0
 /* ----------------------------------------------------------------- */
 ///
 /// Read
 ///
 /// <summary>
 /// 既読設定にします。
 /// </summary>
 ///
 /// <param name="src">RssEntry オブジェクト</param>
 /// <param name="item">RssItem オブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void Read(this RssEntry src, RssItem item)
 {
     if (item != null && item.Status != RssItemStatus.Read)
     {
         src.Count   = Math.Max(src.UnreadItems.Count() - 1, 0);
         item.Status = RssItemStatus.Read;
     }
 }
Esempio n. 4
0
 /* ----------------------------------------------------------------- */
 ///
 /// Shrink
 ///
 /// <summary>
 /// 既読記事を削除します。
 /// </summary>
 ///
 /// <param name="src">RSS フィード</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void Shrink(this RssEntry src)
 {
     for (var i = src.Items.Count - 1; i >= 0; --i)
     {
         if (src.Items[i].Status == RssItemStatus.Read)
         {
             src.Items.RemoveAt(i);
         }
     }
 }
Esempio n. 5
0
 /* ----------------------------------------------------------------- */
 ///
 /// Reschedule
 ///
 /// <summary>
 /// RSS フィードのチェック方法を再設定します。
 /// </summary>
 ///
 /// <param name="src">選択項目</param>
 ///
 /* ----------------------------------------------------------------- */
 public void Reschedule(RssEntry src) => _core.Reschedule(src);