A class in Root.Township, Alta.Utilities.
Collection wrapper that logs an error with a stack trace when it is changed during enumeration, so you can find the code that did it.
Constructors
| Member | What it is |
|---|
DebuggingCollection(ICollection<T> internalCollection) | Creates a DebuggingCollection from internalCollection. |
Fields
3 private and internal fields
| Member | What it is |
|---|
private DebuggingCollection<T, T> enumerator | The latest enumerator handed out. |
private ICollection<T> internalCollection | The wrapped collection. |
private static Logger logger | Class logger. |
Properties
| Member | What it is |
|---|
int Count { get; } | Item count of the wrapped collection. |
bool IsReadOnly { get; } | Read-only flag of the wrapped collection. |
Methods
| Member | What it is |
|---|
void Add(T item) | Adds to the wrapped collection. Logs an error first if an enumeration is running. |
void Clear() | Clears the wrapped collection. Logs an error first if an enumeration is running. |
bool Contains(T item) | Passes through to the wrapped collection. |
void CopyTo(T[] array, int arrayIndex) | Passes through to the wrapped collection. |
IEnumerator GetEnumerator() | Returns a tracking enumerator over the wrapped collection. Only the latest one handed out is watched. |
bool Remove(T item) | Removes from the wrapped collection. Logs an error first if an enumeration is running. |
2 private and internal methods
| Member | What it is |
|---|
private void CheckForEnumerationViolation() | Logs an error with a stack trace if the latest enumerator is still running. |
private void RemoveEnumerator() | Callback that stops tracking once enumeration reaches the end. |