Beispiel #1
0
        private void UpdateMsil()
        {
            if (this.currentObject == this.msilRenderedObject)
            {
                return;
            }

            MetadataDeclaration declaration = this.currentObject as MetadataDeclaration;

            if (declaration != null && MsilWriterUtility.CanWriteMsil(declaration))
            {
                if (this.currentObject is ModuleDeclaration)
                {
                    if (MessageBox.Show(this, "This may take a very long time to display. " +
                                        "Do you want to see the MSIL code of the whole module?", "Warning",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        this.tabControl.SelectedTab = this.tabPageProperties;
                        return;
                    }
                }

                StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);

                MsilWriterUtility.WriteMsil(declaration, stringWriter);

                this.textBoxMsil.Text = stringWriter.ToString();

                this.msilRenderedObject = this.currentObject;
            }
            else
            {
                this.textBoxMsil.Text = "Disassembly not available for the current element.";
            }
        }
Beispiel #2
0
        private void SaveMsil(object o)
        {
            SaveMsilParameter parameter = (SaveMsilParameter)o;

            using (StreamWriter streamWriter = new StreamWriter(parameter.FileName, false, Encoding.ASCII))
            {
                MsilWriterUtility.WriteMsil(parameter.Declaration, streamWriter);
            }
        }