Beispiel #1
0
 void AddViewedThread(ViewedThread viewedThread)
 {
     this.viewedThreadsById.Add(viewedThread.ThreadId, viewedThread);
     if (viewedThread.Read)
     {
         ++this.readThreadCount;
     }
 }
Beispiel #2
0
        void RemoveViewedThread(ViewedThread viewedThread)
        {
            if (!this.viewedThreadsById.Remove(viewedThread.ThreadId))
            {
                throw new KeyNotFoundException();
            }

            if (viewedThread.Read)
            {
                --this.readThreadCount;
            }
        }
Beispiel #3
0
        void UpdateViewWithThread(YamsterThread thread)
        {
            bool shouldBeInView = false;

            if (CompiledFunc != null)
            {
                var executionContext = new YqlExecutionContext(this.appContext);
                executionContext.Thread = thread;
                shouldBeInView          = CompiledFunc(executionContext);
            }

            ViewedThread viewedThread = null;
            bool         isInView     = viewedThreadsById.TryGetValue(thread.ThreadId, out viewedThread);

            bool statisticsChanged = false;

            if (isInView)
            {
                if (!shouldBeInView)
                {
                    this.RemoveViewedThread(viewedThread);
                    NotifyViewChanged(YamsterViewChangeType.ModelLeaveView, thread);

                    // TotalItemCount changed
                    statisticsChanged = true;
                }
                else
                {
                    if (thread.Read != viewedThread.Read)
                    {
                        this.readThreadCount += thread.Read ? +1 : -1;
                        viewedThread.Read     = thread.Read;
                        statisticsChanged     = true;
                    }
                }
            }
            else
            {
                if (shouldBeInView)
                {
                    AddViewedThread(new ViewedThread(thread));
                    NotifyViewChanged(YamsterViewChangeType.ModelEnterView, thread);

                    // TotalItemCount changed
                    statisticsChanged = true;
                }
            }

            if (statisticsChanged)
            {
                NotifyViewChanged(YamsterViewChangeType.StatisticsChanged, null);
            }
        }