Class CollectionWithoutDuplicatesBase<T>
- Namespace
- SunamoCollectionWithoutDuplicates
- Assembly
- SunamoCollectionWithoutDuplicates.dll
Base class for collections that automatically prevent duplicate items.
public abstract class CollectionWithoutDuplicatesBase<T>
Type Parameters
TThe type of items in the collection.
- Inheritance
-
CollectionWithoutDuplicatesBase<T>
- Derived
- Inherited Members
- Extension Methods
Constructors
CollectionWithoutDuplicatesBase()
Initializes a new instance of the collection without duplicates.
public CollectionWithoutDuplicatesBase()
CollectionWithoutDuplicatesBase(IList<T>)
Initializes a new instance of the collection without duplicates from an existing list.
public CollectionWithoutDuplicatesBase(IList<T> list)
Parameters
listIList<T>The list to initialize from.
CollectionWithoutDuplicatesBase(int)
Initializes a new instance of the collection without duplicates with a specified initial capacity.
public CollectionWithoutDuplicatesBase(int initialCapacity)
Parameters
initialCapacityintThe initial capacity of the collection.
Properties
AllowNull
Gets or sets whether to allow null values and how to compare items. True = compare items by their string representation. False = compare items normally (not by string). Null = allow null values (cannot compare by string).
public bool? AllowNull { get; set; }
Property Value
- bool?
Collection
Gets or sets the underlying collection of items.
public List<T> Collection { get; set; }
Property Value
- List<T>
ShouldBreakOnConstruction
When true, breaks into debugger on construction. Used for debugging purposes.
public static bool ShouldBreakOnConstruction { get; set; }
Property Value
StringRepresentations
Gets or sets the string representations of items when comparing by string.
public List<string> StringRepresentations { get; set; }
Property Value
StringValue
The string value of the current item being processed.
protected string? StringValue { get; set; }
Property Value
Methods
Add(T)
Adds an item to the collection if it is not already present.
public bool Add(T value)
Parameters
valueTThe item to add.
Returns
- bool
True if the item was added, false if it was a duplicate.
AddRange(IList<T>)
Adds multiple items to the collection, skipping duplicates.
public List<T> AddRange(IList<T> list)
Parameters
listIList<T>The list of items to add.
Returns
- List<T>
A list of items that were not added because they were duplicates.
AddWithIndex(T)
Adds an item to the collection and returns its index.
public abstract int AddWithIndex(T value)
Parameters
valueTThe item to add.
Returns
- int
The index of the item in the collection.
Contains(T)
Determines whether the collection contains the specified item.
public abstract bool? Contains(T value)
Parameters
valueTThe item to check.
Returns
- bool?
True if the item exists, false if not, null if the item is null and nulls are allowed.
DumpAsString(string, object)
This method is not supported and will throw an exception.
public string DumpAsString(string operation, object dumpAsStringHeaderArgs)
Parameters
Returns
- string
Never returns, always throws.
Exceptions
- Exception
Always thrown as this functionality has been moved to sunamo.
IndexOf(T)
Returns the index of the specified item in the collection.
public abstract int IndexOf(T value)
Parameters
valueTThe item to find.
Returns
- int
The zero-based index of the item.
IsComparingByString()
Determines whether the collection compares items by their string representation.
protected abstract bool IsComparingByString()
Returns
- bool
True if comparing by string, false otherwise.