public override object LoadAssembly(string path)
 {
     return(_reflector.LoadAssembly(path));
 }
Esempio n. 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            const string btnOkText   = "OK";
            const string btnStopText = "Stop";

            switch (btnOK.Text)
            {
            case btnStopText:
                _isCancelPending = true;
                return;

            default:
                break;
            }

            string outputDir = txtOutputDir.Text;

            //if (!Directory.Exists(outputDir))
            //{
            //    SimpleMessage.ShowInfo("Please choose output directory");
            //    return;
            //}

            if (_sourceDir != null && _sourceDir.Equals(outputDir))
            {
                OutputDir = String.Empty;
            }
            else
            {
                OutputDir = outputDir;
            }

            try
            {
                btnOK.Text = btnStopText;
                SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, false);
                Application.DoEvents();

                if (_reflector == null)
                {
                    //TODO: better to new instance, but seems resource can't be released
                    _reflector = SimpleReflector.Default;
                }
                _reflector.Optimization = cboOptimization.Text;

                txtInfo.Text = String.Empty;
                WriteLine(String.Format("=== Started at {0} ===\r\n", DateTime.Now));
                Application.DoEvents();

                _isCancelPending = false;
                _host.ResetProgress();

                _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage(cboLanguage.SelectedItem as string);

                for (int i = 0; i < lbAssemblies.Items.Count; i++)
                {
                    string file = lbAssemblies.Items[i] as string;
                    _reflector.LoadAssembly(file);
                }

                for (int i = 0; i < lbAssemblies.Items.Count; i++)
                {
                    if (_isCancelPending)
                    {
                        break;
                    }

                    string file = lbAssemblies.Items[i] as string;
                    _host.SetStatusText(String.Format("Handling {0} ...", file));
                    DisassembleFile(file);
                    Application.DoEvents();
                }

                for (int i = 0; i < lbAssemblies.Items.Count; i++)
                {
                    string file = lbAssemblies.Items[i] as string;
                    _reflector.UnloadAssembly(file);
                }

                if (_isCancelPending)
                {
                    WriteLine("User breaked.\r\n");
                }
            }
            catch (Exception ex)
            {
                WriteLine(String.Format("{0}\r\n\r\n", ex.Message));
            }
            finally
            {
                btnOK.Text = btnOkText;

                SimpleAssemblyExplorer.Utils.EnableUI(this.Controls, true);

                _host.SetStatusText(null);
                _host.ResetProgress();

                if (_reflector != null && _reflector.LanguageManager != null)
                {
                    _reflector.LanguageManager.ActiveLanguage = _reflector.GetLanguage("C#");
                }
            }

            WriteLine(String.Format("=== Completed at {0} ===\r\n", DateTime.Now));
            //this.Close();
        }