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


C# ObservableCollectionEx.UpdateToMatch方法代码示例

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


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

示例1: UpdateToMatchWithANullKeyFuncThrows

        public void UpdateToMatchWithANullKeyFuncThrows()
        {
            var oc = new ObservableCollectionEx<string>();
            var toAdd = new List<string>
            {
                "Existing",
                "Items",
                "Foo",
                "Bar"
            };

            oc.UpdateToMatch<string>(toAdd, null);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:13,代码来源:ObservableCollectionExTest.cs

示例2: UpdateToMatchUpdatesChangedItems

        public void UpdateToMatchUpdatesChangedItems()
        {
            var oc = new ObservableCollectionEx<CollectionItem>
            {
                new CollectionItem("First", 1),
                new CollectionItem("Second", 2),
                new CollectionItem("Third", 3)
            };

            var toChange = new List<CollectionItem>
            {
                new CollectionItem("First", 100),
                new CollectionItem("Second", 200),
                new CollectionItem("Third", 3)
            };

            Func<CollectionItem, CollectionItem, bool> updateAction = (i1, i2) =>
            {
                if (i1.Value != i2.Value)
                {
                    i1.Value = i2.Value;
                    return true;
                }

                return false;
            };

            oc.UpdateToMatch(toChange, i => i.Key, updateAction);

            oc.Single(i => i.Key == "First").Value.Should().Be(100);
            oc.Single(i => i.Key == "Second").Value.Should().Be(200);
            oc.Single(i => i.Key == "Third").Value.Should().Be(3);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:33,代码来源:ObservableCollectionExTest.cs

示例3: UpdateToMatchWithANullCollectionThrows

 public void UpdateToMatchWithANullCollectionThrows()
 {
     var oc = new ObservableCollectionEx<string>();
     oc.UpdateToMatch(null, s => s);
 }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:5,代码来源:ObservableCollectionExTest.cs

示例4: UpdateToMatchReturnsTrueIfItemsAreRemoved

        public void UpdateToMatchReturnsTrueIfItemsAreRemoved()
        {
            var oc = new ObservableCollectionEx<string>
            {
                "Existing",
                "Items"
            };

            var toRemove = new List<string>
            {
                "Items"
            };

            oc.UpdateToMatch(toRemove, s => s).Should().BeTrue();
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:15,代码来源:ObservableCollectionExTest.cs

示例5: UpdateToMatchReturnsTrueIfItemsAreUpdated

        public void UpdateToMatchReturnsTrueIfItemsAreUpdated()
        {
            var oc = new ObservableCollectionEx<CollectionItem>
            {
                new CollectionItem("First", 1),
                new CollectionItem("Second", 2),
                new CollectionItem("Third", 3)
            };

            var toChange = new List<CollectionItem>
            {
                new CollectionItem("First", 1),
                new CollectionItem("Second", 200),
                new CollectionItem("Third", 3)
            };

            Func<CollectionItem, CollectionItem, bool> updateAction = (i1, i2) =>
            {
                if (i1.Value != i2.Value)
                {
                    i1.Value = i2.Value;
                    return true;
                }

                return false;
            };

            oc.UpdateToMatch(toChange, i => i.Key, updateAction).Should().BeTrue();
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:29,代码来源:ObservableCollectionExTest.cs

示例6: UpdateToMatchReturnsTrueIfItemsAreAdded

        public void UpdateToMatchReturnsTrueIfItemsAreAdded()
        {
            var oc = new ObservableCollectionEx<string>
            {
                "Existing",
                "Items"
            };

            var toAdd = new List<string>
            {
                "Existing",
                "Items",
                "Foo",
                "Bar"
            };

            oc.UpdateToMatch(toAdd, s => s).Should().BeTrue();
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:18,代码来源:ObservableCollectionExTest.cs

示例7: UpdateToMatchRemovesMissingItems

        public void UpdateToMatchRemovesMissingItems()
        {
            var oc = new ObservableCollectionEx<string>
            {
                "Existing",
                "Items"
            };

            var toRemove = new List<string>
            {
                "Items"
            };

            oc.UpdateToMatch(toRemove, s => s);

            oc.Should().ContainInOrder(toRemove);
            oc.Should().OnlyContain(s => toRemove.Contains(s));
            oc.Count.Should().Be(1);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:19,代码来源:ObservableCollectionExTest.cs

示例8: UpdateToMatchRaisesCollectionChangeOnlyOnceWithResetIfItemsAreUpdated

        public void UpdateToMatchRaisesCollectionChangeOnlyOnceWithResetIfItemsAreUpdated()
        {
            var oc = new ObservableCollectionEx<CollectionItem>
            {
                new CollectionItem("First", 1),
                new CollectionItem("Second", 2),
                new CollectionItem("Third", 3)
            };

            var toChange = new List<CollectionItem>
            {
                new CollectionItem("First", 1),
                new CollectionItem("Second", 200),
                new CollectionItem("Third", 3)
            };

            Func<CollectionItem, CollectionItem, bool> updateAction = (i1, i2) =>
            {
                if (i1.Value != i2.Value)
                {
                    i1.Value = i2.Value;
                    return true;
                }

                return false;
            };

            var itemCount = 0;
            var eventCount = 0;
            var action = NotifyCollectionChangedAction.Add;

            oc.CollectionChanged += (sender, args) =>
            {
                ++eventCount;
                itemCount = oc.Count;
                action = args.Action;
            };

            oc.UpdateToMatch(toChange, i => i.Key, updateAction).Should().BeTrue();

            itemCount.Should().Be(3);
            eventCount.Should().Be(1);
            action.Should().Be(NotifyCollectionChangedAction.Reset);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:44,代码来源:ObservableCollectionExTest.cs

示例9: UpdateToMatchRaisesCollectionChangeOnlyOnceWithResetIfItemsAreRemoved

        public void UpdateToMatchRaisesCollectionChangeOnlyOnceWithResetIfItemsAreRemoved()
        {
            var oc = new ObservableCollectionEx<string>
            {
                "Existing",
                "Items"
            };

            var toRemove = new List<string>
            {
                "Items"
            };

            var itemCount = 0;
            var eventCount = 0;
            var action = NotifyCollectionChangedAction.Add;

            oc.CollectionChanged += (sender, args) =>
            {
                ++eventCount;
                itemCount = oc.Count;
                action = args.Action;
            };

            oc.UpdateToMatch(toRemove, s => s);

            itemCount.Should().Be(1);
            eventCount.Should().Be(1);
            action.Should().Be(NotifyCollectionChangedAction.Reset);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:30,代码来源:ObservableCollectionExTest.cs

示例10: UpdateToMatchAddsNewItems

        public void UpdateToMatchAddsNewItems()
        {
            var oc = new ObservableCollectionEx<string>
            {
                "Existing",
                "Items"
            };

            var toAdd = new List<string>
            {
                "Existing",
                "Items",
                "Foo",
                "Bar"
            };

            oc.UpdateToMatch(toAdd, s => s);

            oc.Should().ContainInOrder(toAdd);
            oc.Should().OnlyContain(s => toAdd.Contains(s));
            oc.Count.Should().Be(4);
        }
开发者ID:jimbobbennett,项目名称:JimLib,代码行数:22,代码来源:ObservableCollectionExTest.cs


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