public commandTreeDescription(String __name, graphNode __parent) { parent = __parent; name = __name; commandTreeDescription __p = parent as commandTreeDescription; __p.Add(this, __name); }
/// <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); }