/// <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); } } }
/** * 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); }
/** * Returns the unread count for the specified state. */ internal int GetCountForState(UnreadState state, IResource res) { if (state.IsCounterValid(res) || (state != _curUnreadState && !state.IsPersistent)) { return(state.GetCountFromBuffer(res)); } int count; IUnreadCountProvider provider = (IUnreadCountProvider)_unreadCountProviders [res.Type]; if (provider == null) { count = state.IsPersistent ? res.GetIntProp(_propUnreadCount) : GetUnreadCountFromLinks(res, state); } else { count = GetProviderUnreadCount(res, state, provider); } state.UpdateUnreadCounter(res, count); return(count); }