⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assemblyanalyserview.cs

📁 全功能c#编译器
💻 CS
字号:
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Mike Krueger" email="mike@icsharpcode.net"/>
//     <version value="$version"/>
// </file>

using System;
using System.Collections;
using System.Reflection;
using System.Security.Policy;
using System.Threading;
using System.Windows.Forms;

using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Services;
using ICSharpCode.SharpDevelop.Gui.HtmlControl;
using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Internal.Project;

namespace ICSharpCode.AssemblyAnalyser
{
	/// <summary>
	/// Description of AssemblyAnalyserView.	
	/// </summary>
	public class AssemblyAnalyserView : AbstractViewContent
	{
		public static AssemblyAnalyserView AssemblyAnalyserViewInstance = null;
		
		AssemblyAnalyserControl assemblyAnalyserControl;
		
		AppDomain        analyserDomain  = null;
		AssemblyAnalyser currentAnalyser = null;
		public override Control Control {
			get {
				return assemblyAnalyserControl;
			}
		}
		public override bool IsViewOnly {
			get {
				return true;
			}
		}
		
		public override bool IsReadOnly {
			get {
				return false;
			}
		}
		
		public AssemblyAnalyserView() : base("Assembly Analyser")
		{
			AssemblyAnalyserViewInstance = this;
			assemblyAnalyserControl = new AssemblyAnalyserControl();
			IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
			projectService.StartBuild += new EventHandler(ProjectServiceStartBuild);
			projectService.EndBuild   += new EventHandler(ProjectServiceEndBuild);
			RefreshProjectAssemblies();
		}
		
		public void RefreshProjectAssemblies()
		{
			if (currentAnalyser == null) {
				currentAnalyser = CreateRemoteAnalyser();
			}
			IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
			ArrayList projectCombineEntries = Combine.GetAllProjects(projectService.CurrentOpenCombine);
			assemblyAnalyserControl.ClearContents();
			foreach (ProjectCombineEntry projectEntry in projectCombineEntries) {
				string outputAssembly = projectService.GetOutputAssemblyName(projectEntry.Project);
				assemblyAnalyserControl.AnalyzeAssembly(currentAnalyser, outputAssembly);
			}
			assemblyAnalyserControl.PrintAllResolutions();
		}
		
		public override void Load(string fileName)
		{
		}
		
		public override void Dispose()
		{
			DisposeAnalyser();
			
			IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
			projectService.StartBuild -= new EventHandler(ProjectServiceStartBuild);
			projectService.EndBuild   -= new EventHandler(ProjectServiceEndBuild);
			
			IStatusBarService statusBarService = (IStatusBarService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
			
			statusBarService.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}");
			AssemblyAnalyserViewInstance = null;
		}
		
		void DisposeAnalyser()
		{
			currentAnalyser = null;
			AppDomain.Unload(analyserDomain);
			analyserDomain = null;
		}
		
		void ProjectServiceStartBuild(object sender, EventArgs e)
		{
			assemblyAnalyserControl.ClearContents();
			DisposeAnalyser();
		}
		
		void ProjectServiceEndBuild(object sender, EventArgs e)
		{
			assemblyAnalyserControl.Invoke(new ThreadStart(RefreshProjectAssemblies));
		}
		
		AssemblyAnalyser CreateRemoteAnalyser()
		{
			AppDomainSetup setup = new AppDomainSetup();
			Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
			setup.ApplicationName = "Analyser";
			setup.ApplicationBase = Application.StartupPath;

			analyserDomain = AppDomain.CreateDomain("AnalyserDomain", evidence, setup);
			return (AssemblyAnalyser)analyserDomain.CreateInstanceAndUnwrap(
				typeof(AssemblyAnalyser).Assembly.FullName, 
				typeof(AssemblyAnalyser).FullName,
				false, BindingFlags.Default,null,null,null,null,null);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -