示例#1
0
        /// <summary>
        /// Adjusts the unread count for the specified resource stored in the specified
        /// count map by the specified delta value.
        /// </summary>
        private void AdjustUnreadCount(IResource res, int delta, UnreadState state)
        {
            if (!state.IsPersistent && !state.IsCounterValid(res))
            {
                return;
            }

            int count;

            if (state.IsCounterValid(res) || (state.IsPersistent && !_unreadCountProviders.Contains(res.Type)))
            {
                count = state.GetUnreadCount(res) + delta;
            }
            else
            {
                // this will initiate a new count calculation which will already take into account
                // the new unread state of the resource
                count = state.GetUnreadCount(res);
            }
            if (count >= 0)
            {
                state.UpdateUnreadCounter(res, count);
                if (state.IsPersistent && !_unreadCountProviders.Contains(res.Type))
                {
                    MarkUnreadCounterChanged(res);
                }
            }
        }
示例#2
0
        /**
         * Returns the persistent unread counter for the specified resource
         * (the counter which is not view-specific and which is saved in the
         * resource store).
         */

        public int GetPersistentUnreadCount(IResource res)
        {
            if (_defaultUnreadState.IsCounterValid(res))
            {
                return(_defaultUnreadState.GetUnreadCount(res));
            }

            int count = res.GetIntProp(_propUnreadCount);

            _defaultUnreadState.UpdateUnreadCounter(res, count);
            return(count);
        }