public static void Traverse(this IActivity activity, TraverseArg traverse) { traverse.Start?.Invoke(activity); traverse.Action?.Invoke(activity); foreach (var ch in activity.EnumChildren()) ch.Traverse(traverse); traverse.End?.Invoke(activity); }
public static async ValueTask TraverseAsync(this IActivity activity, Func <IActivity, ValueTask> onAction) { await onAction(activity); foreach (var ch in activity.EnumChildren()) { await ch.TraverseAsync(onAction); } }