Пример #1
0
        public void TestGetInsertionIndex()
        {
            IMultiDimensionalArray <int> ints = new MultiDimensionalArray <int> {
                1, 2, 40, 50
            };

            Assert.AreEqual(2, MultiDimensionalArrayHelper.GetInsertionIndex(3, ints));
            Assert.AreEqual(0, MultiDimensionalArrayHelper.GetInsertionIndex(0, ints));
            Assert.AreEqual(4, MultiDimensionalArrayHelper.GetInsertionIndex(60, ints));
            Assert.AreEqual(1, MultiDimensionalArrayHelper.GetInsertionIndex(2, ints));
            Assert.AreEqual(0, MultiDimensionalArrayHelper.GetInsertionIndex(2, new MultiDimensionalArray <int>()));
        }
Пример #2
0
        private void UpdateInsertionIndex(FunctionValuesChangedEventArgs e, IList <T> values)
        {
            if ((typeof(T) == typeof(string)))
            {
                return; // doesn't matter, it is always unique + we don't care about objects
            }

            var oldIndex = e.Index;

            e.Index = MultiDimensionalArrayHelper.GetInsertionIndex((T)e.Item, values);

            if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                if (e.Index > oldIndex) // !@#@#??????
                {
                    e.Index--;
                }
            }
        }
 protected override int GetInsertionStartIndex(IList valuesToInsert)
 {
     return(MultiDimensionalArrayHelper.GetInsertionIndex(valuesToInsert[0], (IList)values2));
 }