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


C# ObservableCollection.PushChangesTo方法代码示例

本文整理汇总了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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:13,代码来源:PushChangesToTest.cs

示例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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:14,代码来源:PushChangesExecutionTest.cs

示例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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:14,代码来源:PushChangesToTest.cs

示例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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:20,代码来源:PushChangesToTest.cs

示例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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:14,代码来源:PushChangesExecutionTest.cs

示例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);
        }
开发者ID:gja,项目名称:ListMajik,代码行数:13,代码来源:PushChangesToTest.cs


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