Enhanced C#
Language of your choice: library documentation
Public fields | Public Member Functions | List of all members
Loyc.Collections.ListChangeInfo< T > Struct Template Reference

Contains information about how a collection is about to change. More...


Source file:

Remarks

Contains information about how a collection is about to change.

Template Parameters
TType of element in the collection

In contrast to NotifyCollectionChangedEventArgs, this object represents changes that are about to happen, not changes that have happened already.

See also
INotifyListChanging<T>

Public fields

ListChangeInfo(IListSource< T > collection, NotifyCollectionChangedAction action, int index, int sizeChange, IListSource< T > newItems=null) readonly NotifyCollectionChangedAction Action
 This contructor is meant for ListChanging events only (not ListChanged). It computes the OldItems property automatically, on-demand, if the user gets it. More...
 
readonly int Index
 Gets the index at which the add, remove, or change operation starts. If the collection is not a list (e.g. it is a dictionary), this should be Int32.MinValue. More...
 
int NewStartingIndex => Index
 Returns Index. Exists for compatibility with NotifyCollectionChangedEventArgs. More...
 
int OldStartingIndex => Index
 Returns Index. Exists for compatibility with NotifyCollectionChangedEventArgs. More...
 
readonly int SizeChange
 Gets the amount by which the collection size changes. When items are being added, this is positive, and when items are being removed, this is negative. This is 0 when existing items are only being replaced. More...
 
IListSource< T > _collection
 
IListSource< T > NewItems => _newItems
 Represents either new item(s) that are being added to the collection, or item(s) that are replacing existing item(s) in the collection. When items are being removed from an indexed list, this member is either null or empty. More...
 
IListSource< T > OldItems => _oldItems ?? ComputeOldItems()
 This member may provide a list of old items that are being removed or replaced in the collection. It may be null when items are being added. More...
 

Public Member Functions

 ListChangeInfo (NotifyCollectionChangedAction action, int index, int sizeChange, IListSource< T > newItems)
 Initializes the members of ListChangeInfo<T>. More...
 
 ListChangeInfo (NotifyCollectionChangedAction action, int index, int sizeChange, IListSource< T > newItems, IListSource< T > oldItems)
 

Constructor & Destructor Documentation

◆ ListChangeInfo()

Loyc.Collections.ListChangeInfo< T >.ListChangeInfo ( NotifyCollectionChangedAction  action,
int  index,
int  sizeChange,
IListSource< T >  newItems 
)
inline

Initializes the members of ListChangeInfo<T>.

Member Data Documentation

◆ Action

ListChangeInfo (IListSource<T> collection, NotifyCollectionChangedAction action, int index, int sizeChange, IListSource<T> newItems = null) readonly NotifyCollectionChangedAction Loyc.Collections.ListChangeInfo< T >.Action

This contructor is meant for ListChanging events only (not ListChanged). It computes the OldItems property automatically, on-demand, if the user gets it.

Parameters
collectionThe list that is about to change.
actionShould be Remove, Reset or Replace.

Gets a value that indicates the type of change being made to the collection.

◆ Index

readonly int Loyc.Collections.ListChangeInfo< T >.Index

Gets the index at which the add, remove, or change operation starts. If the collection is not a list (e.g. it is a dictionary), this should be Int32.MinValue.

◆ NewItems

IListSource<T> Loyc.Collections.ListChangeInfo< T >.NewItems => _newItems

Represents either new item(s) that are being added to the collection, or item(s) that are replacing existing item(s) in the collection. When items are being removed from an indexed list, this member is either null or empty.

In a ListChanged event, the collection returned from this property could be a slice that will be invalid after the event is over. Avoid storing it without making a copy.

◆ NewStartingIndex

int Loyc.Collections.ListChangeInfo< T >.NewStartingIndex => Index

Returns Index. Exists for compatibility with NotifyCollectionChangedEventArgs.

◆ OldItems

IListSource<T> Loyc.Collections.ListChangeInfo< T >.OldItems => _oldItems ?? ComputeOldItems()

This member may provide a list of old items that are being removed or replaced in the collection. It may be null when items are being added.

In a ListChanging event, the collection returned from this property may be empty if the list is being sorted in-place, since it is not known what the new list will be. In any case, this property is typically a slice and therefore is not valid after the event is over; avoid storing it without making a copy.

◆ OldStartingIndex

int Loyc.Collections.ListChangeInfo< T >.OldStartingIndex => Index

Returns Index. Exists for compatibility with NotifyCollectionChangedEventArgs.

◆ SizeChange

readonly int Loyc.Collections.ListChangeInfo< T >.SizeChange

Gets the amount by which the collection size changes. When items are being added, this is positive, and when items are being removed, this is negative. This is 0 when existing items are only being replaced.