Visual Basic (Declaration) | |
---|---|
Public Enum DuplicateHandling Inherits System.Enum |
C# | |
---|---|
public enum DuplicateHandling : System.Enum |
Member | Description |
---|---|
FirstValueWins | Remove all but the first item of duplicates |
LastValueWins | Remove all but the last item of duplicates |
None | Do nothing and pass-through all duplicates |
RaisesException | Throw an error on duplicates |
Library/Library.Test/TestOrderedEnumeration.cs
C# | Copy Code |
---|---|
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0]; OrderedKeyValuePairs<int, int> ordered; ordered = new OrderedKeyValuePairs<int, int>(e); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer)); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(0x10000, ordered.InMemoryLimit); Assert.AreEqual(null, ordered.Serializer); ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(0x10000, ordered.InMemoryLimit); Assert.AreEqual(null, ordered.Serializer); KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32); ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(0x10000, ordered.InMemoryLimit); Assert.AreEqual(ser, ordered.Serializer); ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(42, ordered.InMemoryLimit); Assert.AreEqual(ser, ordered.Serializer); ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(0x10000, ordered.InMemoryLimit); Assert.IsNotNull(ordered.Serializer); ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42); Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>); Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>); Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling); Assert.AreEqual(42, ordered.InMemoryLimit); Assert.IsNotNull(ordered.Serializer); |
VB.NET | Copy Code |
---|---|
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {} Dim ordered As OrderedKeyValuePairs(Of Integer, Integer) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(&H10000, ordered.InMemoryLimit) Assert.AreEqual(Nothing, ordered.Serializer) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(&H10000, ordered.InMemoryLimit) Assert.AreEqual(Nothing, ordered.Serializer) Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(&H10000, ordered.InMemoryLimit) Assert.AreEqual(ser, ordered.Serializer) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(42, ordered.InMemoryLimit) Assert.AreEqual(ser, ordered.Serializer) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(&H10000, ordered.InMemoryLimit) Assert.IsNotNull(ordered.Serializer) ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42) Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer)) Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer)) Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling) Assert.AreEqual(42, ordered.InMemoryLimit) Assert.IsNotNull(ordered.Serializer) |
System.Object
System.ValueType
System.Enum
CSharpTest.Net.Collections.DuplicateHandling
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
CSharpTest.Net.Collections NamespaceDuplicateHandling BulkInsertOptions.DuplicateHandling
IEnumerable
IEnumerable
DuplicateHandling OrderedEnumeration
IEnumerable