本文整理汇总了C#中ObservableCollection.PushChangesTo方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.PushChangesTo方法的具体用法?C# ObservableCollection.PushChangesTo怎么用?C# ObservableCollection.PushChangesTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.PushChangesTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldOnlyAddEvenNumbers
public void ShouldOnlyAddEvenNumbers()
{
var source = new ObservableCollection<int>();
var dest = new List<int>();
source.PushChangesTo(dest).AddOnlyIf(NumberIsEven);
source.Add(1);
dest.ShouldNotContain(1);
source.Add(2);
dest.ShouldContain(2);
}
示例2: ShouldExecuteAfterAdding
public void ShouldExecuteAfterAdding()
{
var source = new ObservableCollection<int>();
var dest = new List<int>();
source.PushChangesTo(dest).If(NumberIsEven)
.Execute(IncrementCount).AfterAdding();
source.Add(1);
notifiedCount.ShouldBe(0);
source.Add(2);
notifiedCount.ShouldBe(1);
}
示例3: ShouldMaintainInitialDifferences
public void ShouldMaintainInitialDifferences()
{
var source = new ObservableCollection<int>();
var dest = new List<int>();
source.Add(1);
source.PushChangesTo(dest);
dest.ShouldNotContain(1);
source.Remove(1);
dest.ShouldNotContain(1);
}
示例4: ShouldActAsAnEvenFilter
public void ShouldActAsAnEvenFilter()
{
var source = new ObservableCollection<int>();
var dest = new List<int>();
source.PushChangesTo(dest).If(NumberIsEven);
source.Add(1);
dest.ShouldNotContain(1);
source.Add(2);
dest.ShouldContain(2);
source.Remove(2);
dest.ShouldNotContain(2);
dest.Add(1);
source.Remove(1);
dest.ShouldContain(1);
}
示例5: ShouldExecuteCallBacksInCorrectOrder
public void ShouldExecuteCallBacksInCorrectOrder()
{
var source = new ObservableCollection<int>();
var dest = new List<int> {1, 2, 3};
source.PushChangesTo(dest)
.Execute(item => dest.Count.ShouldBe(3)).BeforeAdding()
.Execute(item => dest.Count.ShouldBe(4)).AfterAdding()
.Execute(item => dest.Count.ShouldBe(4)).BeforeRemoving()
.Execute(item => dest.Count.ShouldBe(3)).AfterRemoving();
source.Add(4);
source.Remove(4);
}
示例6: ShouldPushChangesToAListGivenAMapping
public void ShouldPushChangesToAListGivenAMapping()
{
var source = new ObservableCollection<int>();
var dest = new List<float>();
source.PushChangesTo(dest).WithMapping(i => i);
source.Add(1);
dest.ShouldContain(1.00f);
source.Remove(1);
dest.ShouldNotContain(1.00f);
}