Esempio n. 1
0
        /// <summary>
        /// Insert the requested pull request into the backing List directly in a sorted order.
        /// </summary>
        /// <param name="element">The element to insert.</param>
        private void InsertElementSorted([NotNull] PullRequestViewElement element)
        {
            // Implement sorted insertion to keep the list sorted as the UI is refreshed
            // with results that are being streamed back as they are received.
            //
            // List<T>.BinarySearch(...) is documented to return:
            //
            //   The zero-based index of item in the sorted List<T>, if item is found; otherwise,
            //   a negative number that is the bitwise complement of the index of the next element
            //   that is larger than item or, if there is no larger element, the bitwise complement of Count.
            //
            // As we know there will be no matching items in the list, we can use the  bitwise compliment
            // directly as the insertion index into the list.
            //
            var insertionIndex = m_backingData.BinarySearch(element);

            m_backingData.Insert(~insertionIndex, element);

            // Force the UI Loop to re-render this view.
            //
            SetSource(m_backingData);
            Application.Refresh();
        }
Esempio n. 2
0
        private void HandleSelectedPullRequest(int selectedIndex)
        {
            PullRequestViewElement element = (PullRequestViewElement)m_backingList[selectedIndex];

            element.InvokeHandler();
        }