Skip to content

Commit 9bbf096

Browse files
committed
Implement IEnumerable for System groups
1 parent f36d913 commit 9bbf096

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Arch.System/Systems.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define ARCH_METRICS_DISABLED
33
//#endif
44

5+
using System.Collections;
56
using System.Diagnostics;
67
using System.Runtime.CompilerServices;
78
using System.Text;
@@ -85,7 +86,7 @@ public virtual void Dispose(){}
8586
/// They will run in order.
8687
/// </summary>
8788
/// <typeparam name="T">The type passed to the <see cref="ISystem{T}"/>.</typeparam>
88-
public class Group<T> : ISystem<T>
89+
public class Group<T> : ISystem<T>, IEnumerable<ISystem<T>>
8990
{
9091
#if !ARCH_METRICS_DISABLED
9192
private readonly Meter _meter;
@@ -347,6 +348,21 @@ public override string ToString()
347348

348349
return $"Group = {{ {nameof(Name)} = {Name}, Systems = {{ {stringBuilder} }} }} ";
349350
}
351+
352+
/// <inheritdoc/>
353+
public IEnumerator<ISystem<T>> GetEnumerator()
354+
{
355+
foreach (var entry in _systems)
356+
{
357+
yield return entry.System;
358+
}
359+
}
360+
361+
/// <inheritdoc/>
362+
IEnumerator IEnumerable.GetEnumerator()
363+
{
364+
return GetEnumerator();
365+
}
350366

351367
/// <summary>
352368
/// The struct <see cref="SystemEntry"/> represents the given <see cref="ISystem{T}"/> in the <see cref="Group{T}"/> with all its performance statistics.

0 commit comments

Comments
 (0)