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


C# EntitySet.RemoveAt方法代码示例

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


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

示例1: ListChanged_WithSource

        public void ListChanged_WithSource()
        {
            // When is ListChanged emitted?
            // It's not always when you think it would be.
            var people = new EntitySet<Person>();
            var events = new List<ListChangedEventArgs>();
            people.ListChanged += (o, e) => events.Add(e);

            // This is also true if Enumerable.Empty<Person>() is used here.
            people.SetSource(new[]{
                new Person { FirstName = "(", LastName = ")" },
            });
            AssertEqual(events);
            Assert.IsTrue(people.IsDeferred);

            // *Initial* Add()/AddRange() is ignored.
            people.Add(new Person { FirstName = "A", LastName = "B" });
            people.AddRange(new[]{
                new Person { FirstName = "1", LastName = "2" },
                new Person { FirstName = "<", LastName = ">" },
            });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.IsTrue(people.IsDeferred);
            AssertEqual(events);

            events.Clear();
            people.Clear();
            AssertEqual(events, 
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.Reset, 0, -1));
            Assert.IsFalse(people.IsDeferred);

            // Add()/AddRange() after a Clear has events.
            events.Clear();
            people.Add(new Person { FirstName = "A", LastName = "B" });
            people.AddRange(new[]{
                new Person { FirstName = "1", LastName = "2" },
                new Person { FirstName = "<", LastName = ">" },
            });
            AssertEqual(events, 
                new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 2, -1));

            events.Clear();
            var p = new Person { FirstName = "{", LastName = "}" };
            people.Insert(1, p);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1));

            events.Clear();
            Assert.IsTrue(people.Remove(p));
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 1, -1));

            events.Clear();
            people.RemoveAt(0);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1));

            events.Clear();
            people[0] = p;
            AssertEqual(events,
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:66,代码来源:EntitySetTest.cs

示例2: SanityChecking

        public void SanityChecking()
        {
            var people = new EntitySet<Person>();
            bool changed = false;
            people.ListChanged += (o, e) => {
                changed = true;
            };

            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(0, people.Count);
            Assert.IsFalse(people.IsDeferred);

            people.Add(new Person { FirstName = "A", LastName = "B" });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            // WTF?!
            Assert.IsFalse(changed);

            changed = false;
            people.Add(new Person { FirstName = "1", LastName = "2" });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(2, people.Count);
            // WTF?!
            Assert.IsFalse(changed);


            changed = false;
            people.RemoveAt(0);
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            Assert.IsTrue(changed);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:34,代码来源:EntitySetTest.cs

示例3: ListChanged_NoSource

        public void ListChanged_NoSource()
        {
            // When is ListChanged emitted?
            // It's not always when you think it would be.
            // It depends on whether there's a Source present.
            var people = new EntitySet<Person>();
            var events = new List<ListChangedEventArgs> ();
            people.ListChanged += (o, e) => events.Add(e);

            people.Add(new Person { FirstName = "A", LastName = "B" });
            AssertEqual(events);

            events.Clear();
            people.Clear();
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.Reset, 0, -1));

            events.Clear();
            people.AddRange(new[]{
                new Person { FirstName = "1", LastName = "2" },
                new Person { FirstName = "<", LastName = ">" },
            });
            AssertEqual(events);

            events.Clear();
            var p = new Person { FirstName = "{", LastName = "}" };
            people.Insert(1, p);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1));

            events.Clear();
            Assert.IsTrue(people.Remove(p));
            AssertEqual(events);

            events.Clear();
            people.RemoveAt(0);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1));

            events.Clear();
            people[0] = p;
            AssertEqual(events,
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:42,代码来源:EntitySetTest.cs


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