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
TThe 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
listChangeAware <T>List The original ChangeAwareList to copy.
copyChangesboolShould 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
itemsIEnumerable<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
capacityintThe 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
indexintThe index to set.
Property Value
- T
Methods
Add(T)
Adds the item to the end of the collection.
Parameters
itemTThe item to add.
AddRange(IEnumerable<T>)
Adds the elements of the specified collection to the end of the collection.
Parameters
collectionIEnumerable<T>The items to add.
Exceptions
- Argument
Null Exception collectionis 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
itemTThe 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
arrayT[]The array to copy to.
arrayIndexintThe 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
itemTThe 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
itemTThe item to get the index of.
equalityComparerIEqualityComparer <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
indexintThe index to insert at.
itemTThe item to insert.
InsertItem(int, T)
Inserts an item at the specified index.
Parameters
indexintthe index where the item should be inserted.
itemTThe item to insert.
InsertRange(IEnumerable<T>, int)
Inserts the elements of a collection into the List<T> at the specified index.
Parameters
collectionIEnumerable<T>Inserts the specified items.
indexintThe zero-based index at which the new elements should be inserted.
Exceptions
- Argument
Null Exception collectionis null.- Argument
Out OfRange Exception indexis less than 0.-or-indexis 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
itemTThe item to move.
destinationintThe destination index.
OnInsertItems(int, IEnumerable<T>)
Override for custom Insert.
Parameters
startIndexintThe starting index of the items being inserted.
itemsIEnumerable<T>The items being inserted.
OnRemoveItems(int, IEnumerable<T>)
Override for custom remove.
Parameters
startIndexintThe starting index of the items being removed.
itemsIEnumerable<T>The items being removed.
OnSetItem(int, T, T)
Override for custom Set.
Parameters
indexintThe index of the item set.
newItemTThe new item.
oldItemTThe 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
itemTThe 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
itemTThe item to refresh.
indexintThe 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
indexintThe index to refresh.
Remove(T)
Removes the item from the collection and returns true if the item was successfully removed.
Parameters
itemTThe item to remove.
Returns
- bool
If the item was removed.
RemoveAt(int)
Removes the item from the specified index.
Parameters
indexintThe index to remove the item at.
RemoveItem(int)
Remove the item which is at the specified index.
Parameters
indexintThe index being removed.
RemoveItem(int, T)
Removes the item from the specified index - intended for internal use only.
Parameters
indexintThe index being removed.
itemTThe item being removed.
RemoveRange(int, int)
Removes a range of elements from the List<T>.
Parameters
indexintThe zero-based starting index of the range of elements to remove.
countintThe number of elements to remove.
Exceptions
- Argument
Out OfRange Exception indexis less than 0.-or-countis less than 0.- Argument
Exception indexandcountdo 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
indexintThe index of the item to set.
itemTThe item to set.