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.

43 lines
1.2 KiB

  1. // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2. // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
  3. using System.Composition;
  4. using System.Linq;
  5. using ICSharpCode.ILSpy;
  6. using ICSharpCode.ILSpy.TreeNodes;
  7. namespace TestPlugin
  8. {
  9. [ExportContextMenuEntryAttribute(Header = "_Save Assembly")]
  10. [Shared]
  11. public class SaveAssembly : IContextMenuEntry
  12. {
  13. public bool IsVisible(TextViewContext context)
  14. {
  15. return context.SelectedTreeNodes != null && context.SelectedTreeNodes.All(n => n is AssemblyTreeNode);
  16. }
  17. public bool IsEnabled(TextViewContext context)
  18. {
  19. return context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length == 1;
  20. }
  21. public void Execute(TextViewContext context)
  22. {
  23. if (context.SelectedTreeNodes == null)
  24. return;
  25. AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0];
  26. var asm = node.LoadedAssembly.GetMetadataFileOrNull();
  27. if (asm != null)
  28. {
  29. /*SaveFileDialog dlg = new SaveFileDialog();
  30. dlg.FileName = node.LoadedAssembly.FileName;
  31. dlg.Filter = "Assembly|*.dll;*.exe";
  32. if (dlg.ShowDialog(MainWindow.Instance) == true) {
  33. asm.MainModule.Write(dlg.FileName);
  34. }*/
  35. }
  36. }
  37. }
  38. }