public IEnumerable <FormattedString> Permute() { if (!NextParts.Any()) { yield return(ThisPart); } else { foreach (var commandPart in NextParts.SelectMany(o => o.Permute())) { yield return($"{ThisPart} {commandPart}"); } } }
public IEnumerable <CommandPart> PermuteCommands() { if (!NextParts.Any()) { yield return(this); } else { foreach (var commandPart in NextParts.SelectMany(o => o.PermuteCommands())) { yield return(new CommandPart(ThisPart, commandPart)); } } }
public IEnumerable <FormattedString> GetLevel(int level) { if (level == 0) { yield return(ThisPart); } else { foreach (var commandPart in NextParts.SelectMany(o => o.GetLevel(level - 1))) { yield return(commandPart); } } }