public commandTreeDescription Add(String __name)
        {
            var output = new commandTreeDescription(__name, this);

            Add(output, __name);
            //children.Add(output.name, output);
            return(output);
        }
        public commandTreeDescription(String __name, graphNode __parent)
        {
            parent = __parent;
            name   = __name;

            commandTreeDescription __p = parent as commandTreeDescription;

            __p.Add(this, __name);
        }
 public void Add(commandTreeDescription item, String __name)
 {
     item.parent = this;
     item.name   = __name;
     if (!children.Contains(item.name))
     {
         children.Add(item.name, item);
     }
 }
Beispiel #4
0
        internal static void setByMemberInfo(this commandTreeDescription item, MemberInfo __m)
        {
            settingsMemberInfoEntry mi   = new settingsMemberInfoEntry(__m);
            aceMenuItemMeta         mm   = new aceMenuItemMeta(__m);
            commandTreeDescription  desc = item;

            desc.memberMeta = mi;
            desc.menuMeta   = mm;

            desc.name = mm.getEntrySafe(aceMenuItemAttributeRole.DisplayName, mi.name);

            desc.category = mm.getEntrySafe(aceMenuItemAttributeRole.Category).or(mi.categoryName, "Main");

            desc.nodeLevel = commandTreeNodeLevel.group;
        }
Beispiel #5
0
        public static void ReportCommandDesc(this commandTreeDescription item, ITextRender output, String cTitlePrefix = "")
        {
            String cTitle = cTitlePrefix;

            cTitle = cTitle.add(item.name, ".").Trim('.');
            //node.item.menuMeta[aceMenuItemAttributeRole.Category]
            //  cTitle = node.item.menuMeta.getEntrySafe(aceMenuItemAttributeRole.Category).add(cTitle, ".");

            String k = item.menuMeta.getEntrySafe(aceMenuItemAttributeRole.Key);

            if (!k.isNullOrEmpty())
            {
                if (k.Length < 5)
                {
                    cTitle = cTitle.add(" [" + k + "]");
                }
            }
            //node.item.menuMeta.getp
            output.open("div", cTitle, item.description);
            //output.AppendPair("Caption", node.item.name, true, ": ");
            foreach (var pair in item.menuMeta)
            {
                if (imbSciStringExtensions.isNullOrEmpty(pair.Value))
                {
                }
                else
                {
                    switch (pair.Key)
                    {
                    case aceMenuItemAttributeRole.aliasNames:
                        output.AppendPair("Alias", pair.Value, true, ": ");
                        break;

                    case aceMenuItemAttributeRole.Description:
                    case aceMenuItemAttributeRole.ExpandedHelp:
                        output.AppendComment(pair.Value);
                        break;

                    case aceMenuItemAttributeRole.Key:
                        // output.AppendPair("Shortcut / key", pair.Value, true, ": ");
                        break;

                    case aceMenuItemAttributeRole.Category:
                    case aceMenuItemAttributeRole.DisplayName:
                    case aceMenuItemAttributeRole.CmdParamList:
                        break;

                    default:
                        output.AppendPair(pair.Key.ToString(), pair.Value, true, ": ");
                        break;
                    }
                }
            }

            String example = item.name + " ";

            if (item.menuMeta.cmdParams != null)
            {
                if (item.menuMeta.cmdParams.Any())
                {
                    output.AppendLabel("Command arguments: ");
                    String parLine = "";
                    Int32  pi      = 1;

                    List <String> prl = new List <string>();
                    parLine = item.menuMeta.cmdParams.ToString(false, true, true);

                    //foreach (typedParam cmdpar in node.item.menuMeta.cmdParams)
                    //{
                    //    parLine = parLine.add(cmdpar.getString(false), ";");
                    //}

                    output.AppendTable(item.menuMeta.cmdParams.getParameterTable());

                    example = example + parLine;
                }
            }

            output.AppendLabel("Example : ");
            output.AppendCode(example);

            output.close();
        }
Beispiel #6
0
        public static void ReportCommandNode(this commandTreeDescription node, ITextRender output, Boolean paginate, Int32 lastPageLine = 0)
        {
            // output.open("div", node.item.name, node.item.description);
            if (lastPageLine == 0)
            {
                lastPageLine = Convert.ToInt32(output.Length);
            }

            switch (node.nodeLevel)
            {
            case commandTreeNodeLevel.parameter:
                output.AppendPair(node.path.Trim('.'), node.memberMeta.relevantTypeName);

                break;

            case commandTreeNodeLevel.module:
                output.AppendPair(node.path.Trim('.'), node.memberMeta.relevantTypeName);
                foreach (commandTreeDescription snode in node)
                {
                    snode.ReportCommandNode(output, paginate, lastPageLine);
                }
                break;

            case commandTreeNodeLevel.group:
                output.open("div", "Group: " + node.path.Trim('.'), node.description);

                foreach (commandTreeDescription snode in node)
                {
                    snode.ReportCommandNode(output, paginate, lastPageLine);
                }

                output.close();
                output.AppendHorizontalLine();
                break;

            case commandTreeNodeLevel.plugin:
                output.open("div", "Plugin: " + node.path.Trim('.'), node.description);

                foreach (commandTreeDescription tnode in node)
                {
                    node.ReportCommandNode(output, paginate, lastPageLine);
                }
                output.close();
                output.AppendHorizontalLine();
                break;

            case commandTreeNodeLevel.type:
                output.open("div", "Console: " + node.path.Trim('.'), node.description);

                foreach (commandTreeDescription tnode in node)
                {
                    node.ReportCommandNode(output, paginate, lastPageLine);
                }
                output.close();
                output.AppendHorizontalLine();
                break;

            case commandTreeNodeLevel.command:

                String cTitle = "";

                if (node.parent != null)
                {
                    cTitle = node.parent.path + " [" + node.name.toStringSafe() + "]";
                }

                ReportCommandDesc(node, output, cTitle);

                if (paginate)
                {
                    if ((lastPageLine - output.lastLength) >= output.zone.innerBoxedHeight)
                    {
                        lastPageLine = (int)output.lastLength;
                        Paginate();
                    }
                }
                break;
            }

            if (node.helpLines.Any())
            {
                output.open("div", "Additional help:");
                foreach (String ln in node.helpLines)
                {
                    output.AppendLine(ln);
                }
                output.close();
            }

            if (paginate)
            {
                if ((lastPageLine - output.lastLength) >= output.zone.innerBoxedHeight)
                {
                    lastPageLine = (int)output.lastLength;
                    Paginate();
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Builds the type of the tree node for.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="source">The source.</param>
        /// <param name="host">The host.</param>
        /// <returns></returns>
        internal static commandTreeDescription BuildTreeNodeForType(Type type, IAceOperationSetExecutor source, commandTreeDescription parent, String nameOverride = "", commandTreeNodeLevel level = commandTreeNodeLevel.type)
        {
            settingsMemberInfoEntry typeInfo = new settingsMemberInfoEntry(type);

            commandTreeDescription output = parent.Add(nameOverride.or(typeInfo.name, typeInfo.displayName, type.Name));

            commandTree host = parent.root as commandTree;

            output.description = typeInfo.description;
            output.nodeLevel   = level;
            output.helpLines.Add(typeInfo.info_helpTitle);
            output.helpLines.Add(typeInfo.info_helpTips);
            output.helpLines.AddRange(typeInfo.additionalInfo);


            var methods = type.GetMethods(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly);

            aceDictionarySet <String, commandTreeDescription> groups = new aceDictionarySet <string, commandTreeDescription>();

            aceDictionarySet <String, commandTreeDescription> group_nodes = new aceDictionarySet <string, commandTreeDescription>();


            foreach (MemberInfo __m in methods)
            {
                if (__m.Name.StartsWith(aceMenuItemMeta.METHOD_PREFIX))
                {
                    commandTreeDescription desc = new commandTreeDescription();

                    desc.setByMemberInfo(__m);
                    desc.nodeLevel = commandTreeNodeLevel.group;
                    groups.Add(desc.category, desc);
                }
            }

            foreach (String group in groups.Keys.OrderBy(x => x))
            {
                var ordered = groups[group].OrderBy(x => x.name);

                commandTreeDescription gdesc = parent.Add(group);

                gdesc.nodeLevel = commandTreeNodeLevel.group;

                foreach (var cdesc in ordered)
                {
                    cdesc.nodeLevel = commandTreeNodeLevel.command;
                    gdesc.Add(cdesc, cdesc.name);

                    host.flatAccess.Add(cdesc.path, cdesc);
                }
            }

            var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            foreach (PropertyInfo pi in properties)
            {
                if (pi.DeclaringType.Name == "aceCommandConsole")
                {
                    continue;
                }
                if (pi.DeclaringType.Name == "aceAdvancedConsole")
                {
                    continue;
                }

                if (pi.PropertyType.GetInterfaces().Contains(typeof(IAceOperationSetExecutor)))
                {
                    var plugin_instance = source.imbGetPropertySafe(pi) as IAceOperationSetExecutor;
                    var plugin_node     = BuildTreeNodeForType(pi.PropertyType, source, parent, pi.Name, commandTreeNodeLevel.plugin);
                    plugin_node.setByMemberInfo(pi);

                    host.plugins.Add(plugin_node.path, plugin_instance);
                }
                else if (pi.PropertyType.IsValueType || pi.PropertyType.isTextOrNumber() || pi.GetCustomAttributes(false).Any())
                {
                    if (pi.CanWrite)
                    {
                        var prop = parent.Add(pi.Name);

                        prop.setByMemberInfo(pi);
                        prop.nodeLevel = commandTreeNodeLevel.parameter;
                        host.properties.Add(prop.path, pi);
                    }
                }
                else if (pi.PropertyType.IsClass || pi.GetCustomAttributes(false).Any())
                {
                    if (!pi.PropertyType.IsGenericType)
                    {
                        var prop = parent.Add(pi.Name);
                        prop.setByMemberInfo(pi);
                        prop.nodeLevel = commandTreeNodeLevel.module;
                        host.modules.Add(prop.path, pi);
                    }
                }
            }

            return(output);
        }