Class ChangeAwareList<T>
- Namespace
- Dynamic
Data
- Assembly
- DynamicData.dll
A list which captures all changes which are made to it. These changes are recorded until CaptureChanges() at which point the changes are cleared.
Used for creating custom operators.
public class ChangeAwareList<T> : IExtendedList<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable where T : notnull
Type Parameters
T
The item type.
- Inheritance
-
ChangeAwareList<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Extension Methods
Constructors
ChangeAwareList(ChangeAwareList<T>, bool)
Initializes a new instance of the ChangeAwareList<T> class. Clone an existing ChangeAwareList.
Parameters
list
ChangeAware <T>List The original ChangeAwareList to copy.
copyChanges
boolShould the list of changes also be copied over?.
ChangeAwareList(IEnumerable<T>)
Initializes a new instance of the ChangeAwareList<T> class. Create a change aware list with the specified items.
Parameters
items
IEnumerable<T>The items to seed the change aware list with.
ChangeAwareList(int)
Initializes a new instance of the ChangeAwareList<T> class. Create a change aware list with the specified capacity.
Parameters
capacity
intThe initial capacity of the internal lists.
Properties
Capacity
Gets or sets the total number of elements the internal data structure can hold without resizing.
Property Value
Count
Gets the element count.
Property Value
IsReadOnly
Gets a value indicating whether is this collection read only.
Property Value
this[int]
Gets or sets the item at the specified index.
Parameters
index
intThe index to set.
Property Value
- T
Methods
Add(T)
Adds the item to the end of the collection.
Parameters
item
TThe item to add.
AddRange(IEnumerable<T>)
Adds the elements of the specified collection to the end of the collection.
Parameters
collection
IEnumerable<T>The items to add.
Exceptions
- Argument
Null Exception collection
is null.
CaptureChanges()
Create a change set from recorded changes and clears known changes.
Returns
- IChange
Set <T> The change set.
Clear()
Removes all elements from the list.
Contains(T)
Determines whether the element is in the collection.
Parameters
item
TThe item to check.
Returns
- bool
If the item is contained or not.
CopyTo(T[], int)
Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.
Parameters
array
T[]The array to copy to.
arrayIndex
intThe index to start copying to.
GetEnumerator()
Returns
- IEnumerator<T>
IndexOf(T)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
Parameters
item
TThe item to get the index of.
Returns
- int
The index.
IndexOf(T, IEqualityComparer<T>)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection, using the specified comparer.
Parameters
item
TThe item to get the index of.
equalityComparer
IEqualityComparer <T>The equality comparer to use to compare.
Returns
- int
The index.
Insert(int, T)
Inserts an element into the list at the specified index.
Parameters
index
intThe index to insert at.
item
TThe item to insert.
InsertItem(int, T)
Inserts an item at the specified index.
Parameters
index
intthe index where the item should be inserted.
item
TThe item to insert.
InsertRange(IEnumerable<T>, int)
Inserts the elements of a collection into the List<T> at the specified index.
Parameters
collection
IEnumerable<T>Inserts the specified items.
index
intThe zero-based index at which the new elements should be inserted.
Exceptions
- Argument
Null Exception collection
is null.- Argument
Out OfRange Exception index
is less than 0.-or-index
is greater than Count.
Move(int, int)
Moves an item from the original to the destination index.
Parameters
Move(T, int)
Moves the item to the specified destination index.
Parameters
item
TThe item to move.
destination
intThe destination index.
OnInsertItems(int, IEnumerable<T>)
Override for custom Insert.
Parameters
startIndex
intThe starting index of the items being inserted.
items
IEnumerable<T>The items being inserted.
OnRemoveItems(int, IEnumerable<T>)
Override for custom remove.
Parameters
startIndex
intThe starting index of the items being removed.
items
IEnumerable<T>The items being removed.
OnSetItem(int, T, T)
Override for custom Set.
Parameters
index
intThe index of the item set.
newItem
TThe new item.
oldItem
TThe old item.
Refresh(T)
Add a Refresh change for specified index to the list of changes. This is to notify downstream operators to refresh.
Parameters
item
TThe item to refresh.
Returns
- bool
If the item is in the list, returns true.
Refresh(T, int)
Add a Refresh change of the item at the specified index to the list of changes.
This is to notify downstream operators to refresh.
Parameters
item
TThe item to refresh.
index
intThe index to refresh.
RefreshAt(int)
Add a Refresh change of the item at the specified index to the list of changes.
This is to notify downstream operators to refresh.
Parameters
index
intThe index to refresh.
Remove(T)
Removes the item from the collection and returns true if the item was successfully removed.
Parameters
item
TThe item to remove.
Returns
- bool
If the item was removed.
RemoveAt(int)
Removes the item from the specified index.
Parameters
index
intThe index to remove the item at.
RemoveItem(int)
Remove the item which is at the specified index.
Parameters
index
intThe index being removed.
RemoveItem(int, T)
Removes the item from the specified index - intended for internal use only.
Parameters
index
intThe index being removed.
item
TThe item being removed.
RemoveRange(int, int)
Removes a range of elements from the List<T>.
Parameters
index
intThe zero-based starting index of the range of elements to remove.
count
intThe number of elements to remove.
Exceptions
- Argument
Out OfRange Exception index
is less than 0.-or-count
is less than 0.- Argument
Exception index
andcount
do not denote a valid range of elements in the List<T>.
SetItem(int, T)
Replaces the element which is as the specified index wth the specified item.
Parameters
index
intThe index of the item to set.
item
TThe item to set.