mirror of https://github.com/icsharpcode/ILSpy.git
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							41 lines
						
					
					
						
							1.3 KiB
						
					
					
				
			
		
		
	
	
							41 lines
						
					
					
						
							1.3 KiB
						
					
					
				// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) | 
						|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) | 
						|
 | 
						|
using System.Linq; | 
						|
using ICSharpCode.ILSpy; | 
						|
using ICSharpCode.ILSpy.TreeNodes; | 
						|
using Microsoft.Win32; | 
						|
using Mono.Cecil; | 
						|
 | 
						|
namespace TestPlugin | 
						|
{ | 
						|
	[ExportContextMenuEntryAttribute(Header = "_Save Assembly")] | 
						|
	public class SaveAssembly : IContextMenuEntry | 
						|
	{ | 
						|
		public bool IsVisible(TextViewContext context) | 
						|
		{ | 
						|
			return context.SelectedTreeNodes != null && context.SelectedTreeNodes.All(n => n is AssemblyTreeNode); | 
						|
		} | 
						|
		 | 
						|
		public bool IsEnabled(TextViewContext context) | 
						|
		{ | 
						|
			return context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length == 1; | 
						|
		} | 
						|
		 | 
						|
		public void Execute(TextViewContext context) | 
						|
		{ | 
						|
			if (context.SelectedTreeNodes == null) | 
						|
				return; | 
						|
			AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0]; | 
						|
			AssemblyDefinition asm = node.LoadedAssembly.GetAssemblyDefinitionOrNull(); | 
						|
			if (asm != null) { | 
						|
				SaveFileDialog dlg = new SaveFileDialog(); | 
						|
				dlg.FileName = node.LoadedAssembly.FileName; | 
						|
				dlg.Filter = "Assembly|*.dll;*.exe"; | 
						|
				if (dlg.ShowDialog(MainWindow.Instance) == true) { | 
						|
					asm.MainModule.Write(dlg.FileName); | 
						|
				} | 
						|
			} | 
						|
		} | 
						|
	} | 
						|
}
 | 
						|
 |