本文整理汇总了C#中ObservableList.SubscribeArrayChange方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableList.SubscribeArrayChange方法的具体用法?C# ObservableList.SubscribeArrayChange怎么用?C# ObservableList.SubscribeArrayChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableList
的用法示例。
在下文中一共展示了ObservableList.SubscribeArrayChange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInsertChangeNotify
public void TestInsertChangeNotify()
{
var list = new ObservableList<string>("A", "B", "C", "D");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
int expectedIndex = 2;
list.Insert(expectedIndex, "Added");
CollectionAssert.Contains(list.Value, "Added");
CollectionAssert.AreEquivalent(new[]
{
new ArrayChange<string>(ArrayChangeType.add, "Added", expectedIndex),
new ArrayChange<string>(ArrayChangeType.remove, "C", 2),
new ArrayChange<string>(ArrayChangeType.add, "C", 3),
new ArrayChange<string>(ArrayChangeType.remove, "D", 3),
new ArrayChange<string>(ArrayChangeType.add, "D", 4),
},
(ICollection) changes);
}
示例2: TestInsertRange
public void TestInsertRange()
{
var list = new ObservableList<string>("A", "B", "C", "D", "E");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
list.InsertRange(1, Enumerable.Repeat("TEST", 3).Select((s, i) => s + "_" + i));
CollectionAssert.IsSubsetOf(new[] {"TEST_0", "TEST_1", "TEST_2"}, list.Value);
CollectionAssert.AreEquivalent(new[]
{
new ArrayChange<string>(ArrayChangeType.add, "TEST_0", 1),
new ArrayChange<string>(ArrayChangeType.add, "TEST_1", 2),
new ArrayChange<string>(ArrayChangeType.add, "TEST_2", 3),
new ArrayChange<string>(ArrayChangeType.remove, "B", 1),
new ArrayChange<string>(ArrayChangeType.add, "B", 4),
new ArrayChange<string>(ArrayChangeType.remove, "C", 2),
new ArrayChange<string>(ArrayChangeType.add, "C", 5),
new ArrayChange<string>(ArrayChangeType.remove, "D", 3),
new ArrayChange<string>(ArrayChangeType.add, "D", 6),
new ArrayChange<string>(ArrayChangeType.remove, "E", 4),
new ArrayChange<string>(ArrayChangeType.add, "E", 7),
},
(ICollection) changes);
}
示例3: TestPop
public void TestPop()
{
var list = new ObservableList<string>("A", "B", "C", "D", "E");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
CollectionAssert.Contains(list.Value, "E");
Assert.AreEqual(5, list.Count);
var popedValue = list.Pop();
Assert.AreEqual("E", popedValue);
CollectionAssert.DoesNotContain(list.Value, "E");
Assert.AreEqual(4, list.Count);
CollectionAssert.AreEquivalent(new[] {new ArrayChange<string>(ArrayChangeType.remove, "E", 4)},
(ICollection) changes);
}
示例4: TestSort
public void TestSort()
{
var list = new ObservableList<string>("E", "B", "D", "C", "A");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
list.Sort(1, 3, StringComparer.InvariantCultureIgnoreCase);
CollectionAssert.AreEqual(new[] {"E", "B", "C", "D", "A"}, list.Value);
CollectionAssert.AreEquivalent(new[]
{
new ArrayChange<string>(ArrayChangeType.add, "C", 2),
new ArrayChange<string>(ArrayChangeType.remove, "C", 3),
new ArrayChange<string>(ArrayChangeType.add, "D", 3),
new ArrayChange<string>(ArrayChangeType.remove, "D", 2),
},
(ICollection) changes);
}
示例5: TestReverse
public void TestReverse()
{
var list = new ObservableList<string>("E", "B", "D", "C", "A");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
list.Reverse(1, 3);
CollectionAssert.AreEqual(new[] {"E", "C", "D", "B", "A"}, list.Value);
CollectionAssert.AreEquivalent(new[]
{
new ArrayChange<string>(ArrayChangeType.remove, "B", 1),
new ArrayChange<string>(ArrayChangeType.add, "B", 3),
new ArrayChange<string>(ArrayChangeType.add, "C", 1),
new ArrayChange<string>(ArrayChangeType.remove, "C", 3),
},
(ICollection) changes);
}
示例6: TestReplaceValue
public void TestReplaceValue()
{
var list = new ObservableList<string>("E", "B", "D", "C", "A");
IList<ArrayChange<string>> changes = null;
list.SubscribeArrayChange(value => { changes = value; }, "test");
list[2] = "X";
Assert.AreEqual("X", list[2]);
CollectionAssert.AreEquivalent(new[]
{
new ArrayChange<string>(ArrayChangeType.remove, "D", 2),
new ArrayChange<string>(ArrayChangeType.add, "X", 2),
},
(ICollection) changes);
}