private void AddAssembly(AssemblyDefinition assembly) { TreeNode assemblyNode = new TreeNode(assembly.Name.Name); this.tvAssemblyViewer.Nodes.Add(assemblyNode); foreach (ModuleDefinition module in assembly.Modules.OrderBy(m => m.Name)) { TreeNode moduleNode = new TreeNode(module.Name); assemblyNode.Nodes.Add(moduleNode); foreach (String nspace in module.Types.Select(t => t.Namespace).Distinct().OrderBy(name => name)) { TreeNode namespaceNode = new TreeNode(nspace); moduleNode.Nodes.Add(namespaceNode); foreach (TypeDefinition type in module.Types.Where(t => t.Namespace == nspace).OrderBy(t => t.Name)) { TreeNode typeNode = new DefinitionTreeNode(type); namespaceNode.Nodes.Add(typeNode); foreach (MethodDefinition method in type.Methods.OrderBy(m => m.Name)) { TreeNode methodNode = new DefinitionTreeNode(method); typeNode.Nodes.Add(methodNode); } } } } }
public ActionResult GetDefinitionLevel(DefinitionPathInfo defInfo) { var content = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var objects = DefinitionTreeNode.GetObjectsFromPath(content, defInfo.Path, _fieldService, _definitionEditorService, _contentService); return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(objects) }); }
private void TvAssemblyViewer_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node is DefinitionTreeNode) { DefinitionTreeNode node = e.Node as DefinitionTreeNode; if (node.Definition is TypeDefinition) { TypeDefinition type = node.Definition as TypeDefinition; // Get code StringBuilder code = new StringBuilder(); using (StringWriter stream = new StringWriter(code)) { CodeWriter writer = new CodeWriter(stream); TypeBuilder builder = new TypeBuilder(type); builder.Build(writer); } // Create Scintilla code viewer Scintilla scintilla = new Scintilla() { Dock = DockStyle.Fill, Text = code.ToString() }; const int padding = 2; scintilla.Margins[0].Width = scintilla.TextWidth(Style.LineNumber, new string('9', scintilla.Lines.Count.ToString().Length + 1)) + padding; scintilla.Margins[1].Width = 0; scintilla.Margins[2].Width = 0; scintilla.Margins[3].Width = 0; SetScintillaStyles(scintilla); scintilla.ReadOnly = true; TabPage tab = new TabPage(type.Name); tab.Controls.Add(scintilla); tcOutput.TabPages.Add(tab); } else if (node.Definition is MethodDefinition method) { ILGraph graph = new CodeBuilder(method, new TypeNamer(), method.Body.Instructions).Graph; TabPage tab = new TabPage(method.Name); tab.Controls.Add(new ILGraphViewer(graph) { Location = Point.Empty, Anchor = AnchorStyles.Top | AnchorStyles.Left }); tab.AutoScroll = true; tcOutput.TabPages.Add(tab); } } }
public ActionResult GetSingleNode(DefinitionPathInfo defInfo) { var content = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var objFromDef = _definitionEditorService.GetObjectFromPath(content, defInfo.Path, out var notFoundInDef); if (objFromDef == null) { return(Json(new { MissingFieldToDeleteId = defInfo.Path })); } DefinitionTreeNode resultObj = null; switch (objFromDef) { case Content def: { var isFromDictionaries = _definitionEditorService.GetParentObjectFromPath(content, defInfo.Path) is Dictionaries; resultObj = new DefinitionTreeNode(def, null, defInfo.Path, isFromDictionaries, notFoundInDef, _contentService); break; } case Field field: { var existsInQp = true; if (!(field is BaseVirtualField)) { existsInQp = _fieldService.Read(field.FieldId) != null; } resultObj = new DefinitionTreeNode(field, null, defInfo.Path, !existsInQp, notFoundInDef); break; } } return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(resultObj) }); }