`DeviceCollection.GetEnumerator()` now returns a struct IEnumerable<T>
directly to avoid boxing.
Additionally, we can now use `DeviceCollection[int]` as a shortcut to
`FromIndex(int)`.
#region IEnumerable<T> Members
- public IEnumerator<T> GetEnumerator()
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return Devices.GetEnumerator();
}
#region Public Members
+ // This avoids boxing when using foreach loops
+ public List<T>.Enumerator GetEnumerator()
+ {
+ return Devices.GetEnumerator();
+ }
+
+ public T this[int index]
+ {
+ get { return FromIndex(index); }
+ }
+
/// \internal
/// <summary>
/// Adds or replaces a device based on its hardware id.