Esempio n. 1
0
        /// <summary>Assembly worker do work.</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        /// <exception cref="NotImplementedException"></exception>
        private void AssemblyWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            assemblyWorker.ReportProgress(1);

            // Clear tree view
            assemblyExplorer.Tv_Assembly.InvokeIfRequired(() => assemblyExplorer.Tv_Assembly.Nodes.Clear());

            assemblyWorker.ReportProgress(10);

            // Reset the assembly editor property grid item values.
            assemblyExplorer.ResetAssemblyExplorerPropertyGrid();

            assemblyWorker.ReportProgress(20);

            // Get the assembly location from the parameter.
            string assemblyPath = e.Argument.ToString();

            assemblyWorker.ReportProgress(30);

            UpdateStatus(Resources.Analyzer_Build_ReflectionHierarchy);

            // Prepare to decompile the architecture
            assemblyAnalyzer = new AssemblyAnalyzer(assemblyPath);

            assemblyWorker.ReportProgress(40);

            assemblyAnalyzer.Analyze(assemblyPath);

            // Set assembly icon.
            if (assemblyAnalyzer.Icon != null)
            {
                Pb_Icon.Image = assemblyAnalyzer.Icon;
            }

            assemblyWorker.ReportProgress(50);

            assemblyExplorer.Analyze(Tb_Location.Text);

            assemblyWorker.ReportProgress(60);

            UpdateStatus(string.Format(Resources.Analyzer_Build_Preview, Path.GetFileNameWithoutExtension(Tb_Location.Text)));

            // Construct the assembly architecture to a tree view
            TreeNode treeNode = TypesUtil.GenerateTreeView(Tb_Location.Text);

            assemblyWorker.ReportProgress(70);

            // Expand from the root node.
            treeNode.ExpandAll();

            assemblyWorker.ReportProgress(80);

            UpdateStatus(string.Format(Resources.Analyzer_Generate_Documentation, Path.GetFileNameWithoutExtension(Tb_Location.Text)));

            // Add root node to tree view.
            assemblyExplorer.Tv_Assembly.InvokeIfRequired(() => assemblyExplorer.Tv_Assembly.Nodes.Add(treeNode));

            assemblyWorker.ReportProgress(90);

            // Refresh markdown preview contents.
            markdownPreview.Rtb_Preview.InvokeIfRequired(() => markdownPreview.Rtb_Preview.Text = assemblyAnalyzer.AssemblyReport.Contents);

            assemblyWorker.ReportProgress(100);
        }