private ICommandProvider.CommandInfo[] BuildSortedCommandInfos() { var root = new RootCommandNode(_commands.Select(x => x.CommandNode).ToList()); int count = 0; Count(root, ref count); var array = new ICommandProvider.CommandInfo[count]; int i = 0; Build(root, ref i, ref array); return(array); }
private int Build(ICommandNode node, ref int i, ref ICommandProvider.CommandInfo[] array) { var children = new int[node.Children.Count]; for (var index = 0; index < node.Children.Count; index++) { children[index] = Build(node.Children[index], ref i, ref array); } if (node.Redirect != null) { _logger.LogCritical($"Node {node.Name} has redirect. This is unsupported. "); } array[i] = new ICommandProvider.CommandInfo(node.Name, null, node.Type, children, node.IsExecutable, node.Parser); i++; return(i - 1); }