当前位置: 首页>>代码示例>>C#>>正文


C# MultiDimensionalArray.Add方法代码示例

本文整理汇总了C#中MultiDimensionalArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MultiDimensionalArray.Add方法的具体用法?C# MultiDimensionalArray.Add怎么用?C# MultiDimensionalArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MultiDimensionalArray的用法示例。


在下文中一共展示了MultiDimensionalArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestConvertedArray

        public void TestConvertedArray()
        {

            IMultiDimensionalArray<int> intArray = new MultiDimensionalArray<int>(new List<int> { 1, 2, 3, 4, 5 }, new[] { 5 });
            IMultiDimensionalArray<string> stringArray = new ConvertedArray<string, int>(intArray, Convert.ToInt32, Convert.ToString);


            Assert.AreEqual(intArray.Shape, stringArray.Shape);


            Assert.AreEqual("1", stringArray[0]);
            //assignment on the converted array are passed to the source
            stringArray.Add("30");
            Assert.AreEqual(30, intArray[5]);
            intArray.Add(31);
            Assert.AreEqual("31", stringArray[6]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:ConvertedArrayTest.cs

示例2: SetValuesOfAWrongTypeGivesException

 public void SetValuesOfAWrongTypeGivesException()
 {
     IMultiDimensionalArray<DateTime> array = new MultiDimensionalArray<DateTime>();
     array.Add(DateTime.Now);
     ((IList)array)[0] = 1; // <-- exception
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:6,代码来源:MultiDimensionalArrayTest.cs

示例3: AddWrongTypeToValuesGivesException

 public void AddWrongTypeToValuesGivesException()
 {
     IMultiDimensionalArray<DateTime> array = new MultiDimensionalArray<DateTime>();
     array.Add(1); // <-- exception
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:5,代码来源:MultiDimensionalArrayTest.cs

示例4: IndexOnValuesRemoved

 public void IndexOnValuesRemoved()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
     array.Add(2);
     array.Add(3);
     int callCount = 0;
     array.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
                                    {
                                        var args = (MultiDimensionalArrayChangedEventArgs)e;
                                        Assert.AreEqual(new[] { 1 }, args.MultiDimensionalIndex);
                                        callCount++;
                                    };
     array.Remove(3);
     Assert.AreEqual(1, callCount);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:MultiDimensionalArrayTest.cs

示例5: Create1D

        public void Create1D()
        {
            IMultiDimensionalArray array = new MultiDimensionalArray();

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Remove(2);

            log.Info(array.ToString());

            Assert.AreEqual(1, array.Rank);
            Assert.AreEqual(2, array.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayTest.cs

示例6: CopyConstructor

        public void CopyConstructor()
        {
            IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
            array.Add(1);
            array.Add(2);
            array.Add(3);

            Assert.AreEqual(3, array.Shape[0]);
            //create an offline copy
            IMultiDimensionalArray<int> copy = new MultiDimensionalArray<int>(array, array.Shape);
            Assert.AreEqual(3, copy.Count);

            //add an item to the parent and verify it does not add to our copy
            array.Add(5);
            Assert.AreEqual(3, copy.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:16,代码来源:MultiDimensionalArrayTest.cs

示例7: Contains

 public void Contains()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
     array.Add(22);
     //array.SetValues(new[] {1,2,22});
     Assert.IsTrue(array.Contains(22));
     Assert.IsFalse(array.Contains(23));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:MultiDimensionalArrayTest.cs

示例8: UpdateMinMax

        public void UpdateMinMax()
        {
            var array = new MultiDimensionalArray<double>();
            Assert.IsNull(array.MinValue);
            Assert.IsNull(array.MaxValue);

            //action! change the array
            array.Add(0.0d);

            //assert min max got updated
            Assert.AreEqual(0.0d,array.MinValue);
            Assert.AreEqual(0.0d, array.MaxValue);

            //make sure we got insert covered
            array.Insert(1,1.0d);
            Assert.AreEqual(1.0d, array.MaxValue);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:MultiDimensionalArrayTest.cs

示例9: IndexOnValuesAdded

 public void IndexOnValuesAdded()
 {
     IMultiDimensionalArray<int> array = new MultiDimensionalArray<int>();
     int callCount = 0;
     array.Add(2);
     array.CollectionChanged += delegate(object sender, MultiDimensionalArrayChangingEventArgs e)
                                    {
                                        Assert.AreEqual(new[] { 1 }, e.MultiDimensionalIndex);
                                        callCount++;
                                    };
     array.Add(4);
     Assert.AreEqual(1, callCount);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:MultiDimensionalArrayTest.cs

示例10: AddingValueToSortedArrayKeepsOldSubscribtion

        public void AddingValueToSortedArrayKeepsOldSubscribtion()
        {
            var array = new MultiDimensionalArray<TestNotifyPropertyChangedObject> { IsAutoSorted = true };

            var testNotifyPropertyChangedObject = new TestNotifyPropertyChangedObject {Value = 10};
            array.Add(testNotifyPropertyChangedObject);
            array.Add(new TestNotifyPropertyChangedObject { Value = 5 });//this will cause sorting

            int callCount = 0;
            ((INotifyPropertyChanged) array).PropertyChanged += (s, e) => { callCount++; };
            testNotifyPropertyChangedObject.FireChanged();

            Assert.AreEqual(1,callCount);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayTest.cs

示例11: UnsubscribePropertyChangesAfterResize

        public void UnsubscribePropertyChangesAfterResize()
        {
            var testNotifyPropertyChangedObject = new TestNotifyPropertyChangedObject();

            IMultiDimensionalArray<TestNotifyPropertyChangedObject> array = new MultiDimensionalArray<TestNotifyPropertyChangedObject>
            {
                IsAutoSorted = false
            };

            array.Add(testNotifyPropertyChangedObject);
            
            array.Resize(new[] {2, 2});

            Assert.AreEqual(1, testNotifyPropertyChangedObject.GetNumPropertyChangedSubscriptions(), "num property subscriptions");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:MultiDimensionalArrayTest.cs

示例12: BubblePropertyChangesOfInsertedObject

        public void BubblePropertyChangesOfInsertedObject()
        {
            var testNotifyPropertyChangedObject = new TestNotifyPropertyChangedObject();

            IMultiDimensionalArray<TestNotifyPropertyChangedObject> array = new MultiDimensionalArray<TestNotifyPropertyChangedObject>
                                                                                {
                                                                                    IsAutoSorted = false
                                                                                };
            array.Add(new TestNotifyPropertyChangedObject());

            array.InsertAt(0, 0, 1, new[] { testNotifyPropertyChangedObject });

            TestHelper.AssertPropertyChangedIsFired((INotifyPropertyChanged)array, 1, testNotifyPropertyChangedObject.FireChanged);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:14,代码来源:MultiDimensionalArrayTest.cs

示例13: RemoveDoesNothingWhenValueIsNotInArray

        public void RemoveDoesNothingWhenValueIsNotInArray()
        {
            IMultiDimensionalArray<double> array = new MultiDimensionalArray<double>()
                                                       {IsAutoSorted = true};
            array.Add(0.0);
            array.Add(10.0);

            //remove something that was never there. shoud have no effect (just like in List<T>
            array.Remove(11.0d);

            Assert.AreEqual(new[]{0.0,10.0},array);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:12,代码来源:MultiDimensionalArrayTest.cs

示例14: AutoSortedArrayAddsAtCorrectIndex

        public void AutoSortedArrayAddsAtCorrectIndex()
        {
            var array = new MultiDimensionalArray<double>(new[] {1.0, 2.0, 4.0, 5.0}, new[] {4})
                            {
                                IsAutoSorted = true
                            };
            var collectionChangingCount = 0;
            var collectionChangedCount = 0;

            //in should be inserted at index 2
            //changing shows intention..
            array.CollectionChanging += (s, e) =>
                                            {
                                                Assert.AreEqual(NotifyCollectionChangeAction.Add, e.Action);
                                                Assert.AreEqual(3.0, e.Items[0]);
                                                Assert.AreEqual(4, e.Index);
                                                collectionChangingCount++;
                                            };

            //this is what happened.
            array.CollectionChanged += (s, e) =>
                                           {
                                               Assert.AreEqual(NotifyCollectionChangeAction.Add, e.Action);
                                               Assert.AreEqual(3.0, e.Items[0]);
                                               Assert.AreEqual(2, e.Index);
                                               collectionChangedCount++;
                                           };

            //action! add a 3.0
            array.Add(3.0);

            Assert.AreEqual(1, collectionChangingCount);
            Assert.AreEqual(1, collectionChangedCount);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:MultiDimensionalArrayTest.cs

示例15: ReadOnlyAdd

 public void ReadOnlyAdd()
 {
     var array = new MultiDimensionalArray(true, false, 1, new int[1]);
     array.Add(1);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:5,代码来源:MultiDimensionalArrayTest.cs


注:本文中的MultiDimensionalArray.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。