Class ObservableWrap<T, TCollection>
Base class for observable collection wrappers.
Inheritance
Inherited Members
Namespace: TheXDS.MCART.Types.Base
Assembly: MCART.Mvvm.dll
Syntax
public abstract class ObservableWrap<T, TCollection> : ObservableWrapBase, INotifyPropertyChangeBase, IRefreshable, INotifyPropertyChanged, INotifyCollectionChanged, ICollection<T>, IEnumerable<T>, IEnumerable where TCollection : ICollection<T>
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in the collection. |
| TCollection | Type of the collection. |
Constructors
| Edit this page View SourceObservableWrap()
Initializes a new instance of the ObservableWrap<T, TCollection> class.
Declaration
protected ObservableWrap()
ObservableWrap(TCollection)
Initializes a new instance of the ObservableWrap<T, TCollection> class.
Declaration
protected ObservableWrap(TCollection collection)
Parameters
| Type | Name | Description |
|---|---|---|
| TCollection | collection | Initial underlying collection. |
Properties
| Edit this page View SourceCount
Gets the number of elements contained in the collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsReadOnly
Gets a value indicating whether the collection is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
UnderlyingCollection
Gets direct access to the underlying collection wrapped by this ObservableWrap<T, TCollection>.
Declaration
public TCollection? UnderlyingCollection { get; }
Property Value
| Type | Description |
|---|---|
| TCollection |
Methods
| Edit this page View SourceAdd(T)
Adds a new item to the end of the collection.
Declaration
public void Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | Item to add. |
Clear()
Clears the collection.
Declaration
public void Clear()
Contains(T)
Determines whether the underlying sequence contains the specified item.
Declaration
public virtual bool Contains(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | Item to locate in the sequence. |
Returns
| Type | Description |
|---|---|
| bool | true if the sequence contains the specified item; otherwise, false. |
CopyTo(T[], int)
Copies the elements of this collection to an array.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | Destination array. |
| int | arrayIndex | Index in the destination at which copying begins. |
GetEnumerator()
Gets an enumerator that iterates through the collection.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<T> | An enumerator that can be used to iterate over the collection. |
OnGetEnumerator()
Gets an enumerator that iterates through the collection.
Declaration
protected override IEnumerator OnGetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator | An enumerator that can be used to iterate over the collection. |
Overrides
| Edit this page View SourceRefresh()
Forces a notification that the collection has changed.
Declaration
public override void Refresh()
Overrides
| Edit this page View SourceRemove(T)
Removes an item from the collection.
Declaration
public bool Remove(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | Item to remove. |
Returns
| Type | Description |
|---|---|
| bool | true if the item was successfully removed from the collection; false otherwise. Also returns false if the item did not exist in the original ICollection<T>. |
Replace(TCollection)
Removes all items from the underlying collection and replaces them with the items from the specified collection.
Declaration
public void Replace(TCollection newCollection)
Parameters
| Type | Name | Description |
|---|---|---|
| TCollection | newCollection | Collection whose items will be added to the underlying collection. |
Substitute(TCollection?)
Replaces the underlying collection with a new one.
Declaration
public void Substitute(TCollection? newCollection)
Parameters
| Type | Name | Description |
|---|---|---|
| TCollection | newCollection | The collection to set as the underlying collection. |