A class in Root.Township, Alta.Utilities.
A read-only view onto another listened list that can be swapped at runtime. It forwards the target's add, remove and target-changed events as its own, and reads as empty with no target.
Constructors
| Member | What it is |
|---|
ForwardedList() | Creates a ForwardedList with default values. |
Fields
2 private and internal fields
| Member | What it is |
|---|
private List<T> empty | Empty list returned when there is no target. |
private IListenedList<T> target | Backing field for Target. |
Properties
| Member | What it is |
|---|
int Count { get; } | Item count of the current target, or 0 with none. |
T this[int index] { get; } | Item at the index in the current target. |
IListenedList<T> Target { get; } | The list currently forwarded. |
protected List<T> Internal { get; } | The target's backing list, or an empty list when there is no target. |
Events
| Member | What it is |
|---|
event ListItemChangedHandler<T> ItemAdded | Raised when an item is added to the current target. |
event ListItemChangedHandler<T> ItemRemoved | Raised when an item is removed from the current target. |
event TargetChangedHandler<T> TargetChanged | Raised with the old and new target when the target changes, including in nested forwarded lists. |
Methods
| Member | What it is |
|---|
bool Contains(T item) | Whether the current target contains the item. |
IEnumerator<T> GetEnumerator() | Enumerates the current target's items. |
void SetTarget(IListenedList<T> newTarget) | Switches to a new target list, moving event hooks and raising TargetChanged. Items are not re-announced. |
4 private and internal methods
| Member | What it is |
|---|
private void Add(IListenedList<T> list, T item) | Forwards the target's ItemAdded as this list's ItemAdded. |
private IEnumerator System.Collections.IEnumerable.GetEnumerator() | Enumerates the current target's items. |
private void ParentTargetChanged(ForwardedList<T> list, IListenedList<T> oldTarget, IListenedList<T> newTarget) | Passes on a target change from a nested forwarded list. |
private void Remove(IListenedList<T> list, T item) | Forwards the target's ItemRemoved as this list's ItemRemoved. |
Used in
Members of other types that take, return or hold a ForwardedList<T>: