Ejemplo n.º 1
0
        private void DecompileSelectedNode()
        {
            if (treeView1.SelectedItem == null ||
                !(((TreeViewItem)treeView1.SelectedItem).Tag is TypeDefinition))
            {
                codeTextBox.Blocks.Clear();
                return;
            }

            var ty = (TypeDefinition)(((TreeViewItem)treeView1.SelectedItem).Tag);

            var ctx    = new DecompilerContext(ty.Module);
            var astBui = new AstBuilder(ctx);

            astBui.AddType(ty);
            astBui.RunTransformations();
            var outp = new RichTextOutput();

            astBui.GenerateCode(outp);

            //var rn = new Run { Text = outp.ToString() };
            //var pa = new Paragraph();
            //pa.Inlines.Add(rn);

            codeTextBox.Blocks.Clear();
            //codeTextBox.Blocks.Add(pa);

            foreach (var b in outp.GetBlocks())
            {
                codeTextBox.Blocks.Add(b);
            }

            codeTextBox.Selection.Select(codeTextBox.ContentStart, codeTextBox.ContentStart);
        }
        private void DecompileSelectedNode()
        {
            if (treeView1.SelectedItem == null
                || !(((TreeViewItem)treeView1.SelectedItem).Tag is TypeDefinition))
            {
                codeTextBox.Blocks.Clear();
                return;
            }

            var ty = (TypeDefinition)(((TreeViewItem)treeView1.SelectedItem).Tag);

            var ctx = new DecompilerContext(ty.Module);
            var astBui = new AstBuilder(ctx);
            astBui.AddType(ty);
            astBui.RunTransformations();
            var outp = new RichTextOutput();
            astBui.GenerateCode(outp);

            //var rn = new Run { Text = outp.ToString() };
            //var pa = new Paragraph();
            //pa.Inlines.Add(rn);

            codeTextBox.Blocks.Clear();
            //codeTextBox.Blocks.Add(pa);

            foreach (var b in outp.GetBlocks())
            {
                codeTextBox.Blocks.Add(b);
            }

            codeTextBox.Selection.Select(codeTextBox.ContentStart, codeTextBox.ContentStart);
        }