Class TypeConvertedObservableList<TSrc, TDest>
- Namespace
- CarinaStudio.Collections
- Assembly
- CarinaStudio.AppBase.Core.dll
IList<T> which wraps another IList<T> and convert elements to another type. Elements will be updated automatically if source IList<T> implements INotifyCollectionChanged interface.
public abstract class TypeConvertedObservableList<TSrc, TDest> : BaseDisposable, IDisposable, IList, ICollection, IList<TDest>, ICollection<TDest>, INotifyCollectionChanged, INotifyPropertyChanged, IReadOnlyList<TDest>, IReadOnlyCollection<TDest>, IEnumerable<TDest>, IEnumerable
Type Parameters
TSrcType of element of source list.
TDestType of converted elements.
- Inheritance
-
TypeConvertedObservableList<TSrc, TDest>
- Implements
-
IList<TDest>ICollection<TDest>IReadOnlyList<TDest>IReadOnlyCollection<TDest>IEnumerable<TDest>
- Inherited Members
- Extension Methods
Constructors
TypeConvertedObservableList(IList<TSrc>)
Initialize new TypeConvertedObservableList<TSrc, TDest> instance.
protected TypeConvertedObservableList(IList<TSrc> source)
Parameters
sourceIList<TSrc>Source list.
Properties
Count
Get number of elements.
public int Count { get; }
Property Value
this[int]
Get element.
public TDest this[int index] { get; }
Parameters
indexintIndex of element.
Property Value
- TDest
Element.
Methods
Contains(TDest)
Check whether given element is contained in list or not.
public bool Contains(TDest element)
Parameters
elementTDestElement.
Returns
- bool
True if element is contained in list.
ConvertElement(TSrc)
Convert source element to element in this list.
protected abstract TDest ConvertElement(TSrc srcElement)
Parameters
srcElementTSrcElement in source list.
Returns
- TDest
Converted element.
CopyTo(TDest[], int)
Copy elements to array.
public void CopyTo(TDest[] array, int arrayIndex)
Parameters
arrayTDest[]Array to place copied elements.
arrayIndexintIndex of first position in
arrayto place copied elements.
Dispose(bool)
Dispose the list.
protected override void Dispose(bool disposing)
Parameters
disposingboolTrue to release managed resources.
GetEnumerator()
Get IEnumerator<T> to enumerate elements.
public IEnumerator<TDest> GetEnumerator()
Returns
- IEnumerator<TDest>
IndexOf(TDest)
Get index of given element in list.
public int IndexOf(TDest element)
Parameters
elementTDestElement.
Returns
- int
Index of element in list, or -1 if element is not contained in list.
IsEmpty()
Check whether the list is empty or not.
public bool IsEmpty()
Returns
- bool
True if the list is empty.
IsNotEmpty()
Check whether the list is not empty or not.
public bool IsNotEmpty()
Returns
- bool
True if the list is not empty.
ReleaseElement(TDest)
Release converted element.
protected virtual void ReleaseElement(TDest element)
Parameters
elementTDestConverted element.
TrimExcess()
Set the capacity to the actual number of elements in list.
public void TrimExcess()
Events
CollectionChanged
Raised when list changed.
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
PropertyChanged
Raised when property changed.
public event PropertyChangedEventHandler? PropertyChanged