Table of Contents

Class ChangeAwareList<T>

Namespace
DynamicData
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
Extension Methods
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)
WhenAnyMixin.WhenAny<TSender, TRet, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(TSender?, Expression<Func<TSender, T1>>, Expression<Func<TSender, T2>>, Expression<Func<TSender, T3>>, Expression<Func<TSender, T4>>, Expression<Func<TSender, T5>>, Expression<Func<TSender, T6>>, Expression<Func<TSender, T7>>, Expression<Func<TSender, T8>>, Expression<Func<TSender, T9>>, Expression<Func<TSender, T10>>, Expression<Func<TSender, T11>>, Expression<Func<TSender, T12>>, Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, IObservedChange<TSender, T5>, IObservedChange<TSender, T6>, IObservedChange<TSender, T7>, IObservedChange<TSender, T8>, IObservedChange<TSender, T9>, IObservedChange<TSender, T10>, IObservedChange<TSender, T11>, IObservedChange<TSender, T12>, TRet>)

Constructors

ChangeAwareList(ChangeAwareList<T>, bool)

Initializes a new instance of the ChangeAwareList<T> class. Clone an existing ChangeAwareList.

public ChangeAwareList(ChangeAwareList<T> list, bool copyChanges)

Parameters

list ChangeAwareList<T>

The original ChangeAwareList to copy.

copyChanges bool

Should 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.

public ChangeAwareList(IEnumerable<T> 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.

public ChangeAwareList(int capacity = -1)

Parameters

capacity int

The initial capacity of the internal lists.

Properties

Capacity

Gets or sets the total number of elements the internal data structure can hold without resizing.

public int Capacity { get; set; }

Property Value

int

Count

Gets the element count.

public int Count { get; }

Property Value

int

IsReadOnly

Gets a value indicating whether is this collection read only.

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets or sets the item at the specified index.

public T this[int index] { get; set; }

Parameters

index int

The index to set.

Property Value

T

Methods

Add(T)

Adds the item to the end of the collection.

public void Add(T item)

Parameters

item T

The item to add.

AddRange(IEnumerable<T>)

Adds the elements of the specified collection to the end of the collection.

public void AddRange(IEnumerable<T> collection)

Parameters

collection IEnumerable<T>

The items to add.

Exceptions

ArgumentNullException

collection is null.

CaptureChanges()

Create a change set from recorded changes and clears known changes.

public IChangeSet<T> CaptureChanges()

Returns

IChangeSet<T>

The change set.

Clear()

Removes all elements from the list.

public virtual void Clear()

Contains(T)

Determines whether the element is in the collection.

public virtual bool Contains(T item)

Parameters

item T

The 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.

public void CopyTo(T[] array, int arrayIndex)

Parameters

array T[]

The array to copy to.

arrayIndex int

The index to start copying to.

GetEnumerator()

public IEnumerator<T> 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.

public int IndexOf(T item)

Parameters

item T

The 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.

public int IndexOf(T item, IEqualityComparer<T> equalityComparer)

Parameters

item T

The 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.

public void Insert(int index, T item)

Parameters

index int

The index to insert at.

item T

The item to insert.

InsertItem(int, T)

Inserts an item at the specified index.

protected virtual void InsertItem(int index, T item)

Parameters

index int

the index where the item should be inserted.

item T

The item to insert.

InsertRange(IEnumerable<T>, int)

Inserts the elements of a collection into the List<T> at the specified index.

public void InsertRange(IEnumerable<T> collection, int index)

Parameters

collection IEnumerable<T>

Inserts the specified items.

index int

The zero-based index at which the new elements should be inserted.

Exceptions

ArgumentNullException

collection is null.

ArgumentOutOfRangeException

index is less than 0.-or-index is greater than Count.

Move(int, int)

Moves an item from the original to the destination index.

public virtual void Move(int original, int destination)

Parameters

original int

The original.

destination int

The destination.

Move(T, int)

Moves the item to the specified destination index.

public virtual void Move(T item, int destination)

Parameters

item T

The item to move.

destination int

The destination index.

OnInsertItems(int, IEnumerable<T>)

Override for custom Insert.

protected virtual void OnInsertItems(int startIndex, IEnumerable<T> items)

Parameters

startIndex int

The starting index of the items being inserted.

items IEnumerable<T>

The items being inserted.

OnRemoveItems(int, IEnumerable<T>)

Override for custom remove.

protected virtual void OnRemoveItems(int startIndex, IEnumerable<T> items)

Parameters

startIndex int

The starting index of the items being removed.

items IEnumerable<T>

The items being removed.

OnSetItem(int, T, T)

Override for custom Set.

protected virtual void OnSetItem(int index, T newItem, T oldItem)

Parameters

index int

The index of the item set.

newItem T

The new item.

oldItem T

The old item.

Refresh(T)

Add a Refresh change for specified index to the list of changes. This is to notify downstream operators to refresh.

public bool Refresh(T item)

Parameters

item T

The 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.

public void Refresh(T item, int index)

Parameters

item T

The item to refresh.

index int

The 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.

public void RefreshAt(int index)

Parameters

index int

The index to refresh.

Remove(T)

Removes the item from the collection and returns true if the item was successfully removed.

public bool Remove(T item)

Parameters

item T

The item to remove.

Returns

bool

If the item was removed.

RemoveAt(int)

Removes the item from the specified index.

public void RemoveAt(int index)

Parameters

index int

The index to remove the item at.

RemoveItem(int)

Remove the item which is at the specified index.

protected void RemoveItem(int index)

Parameters

index int

The index being removed.

RemoveItem(int, T)

Removes the item from the specified index - intended for internal use only.

protected virtual void RemoveItem(int index, T item)

Parameters

index int

The index being removed.

item T

The item being removed.

RemoveRange(int, int)

Removes a range of elements from the List<T>.

public void RemoveRange(int index, int count)

Parameters

index int

The zero-based starting index of the range of elements to remove.

count int

The number of elements to remove.

Exceptions

ArgumentOutOfRangeException

index is less than 0.-or-count is less than 0.

ArgumentException

index and count 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.

protected virtual void SetItem(int index, T item)

Parameters

index int

The index of the item to set.

item T

The item to set.

See Also