Beispiel #1
0
        /// <summary>
        /// Builds the command tree.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="includeParentTypes">if set to <c>true</c> it will include only this type.</param>
        /// <returns></returns>
        public static commandTree BuildCommandTree(IAceOperationSetExecutor source, Boolean includeParentTypes = true)
        {
            commandTree rootDesc = new commandTree();

            rootDesc.name        = "commands";
            rootDesc.nodeLevel   = commandTreeNodeLevel.root;
            rootDesc.description = $"Reference of console commands available at {source.consoleTitle} command line interface.";
            rootDesc.helpLines.Add(source.consoleHelp);
            rootDesc.helpLines.AddRange(source.helpHeader);
            commandTree output = rootDesc;

            List <Type> types = new List <Type>();

            if (includeParentTypes)
            {
                types = source.GetType().GetBaseTypeList(true, true, typeof(aceOperationSetExecutorBase));
            }
            else
            {
                types.Add(source.GetType());
            }


            types.Reverse();

            foreach (Type t in types)
            {
                if (t.IsInterface)
                {
                    continue;
                }
                if (t.IsClass)
                {
                    output.Add(BuildTreeNodeForType(t, source, output), t.Name);
                }
            }

            return(output);
        }