Browse Source

Added support for dropping nupkg files.

pull/987/head
David Störmer 8 years ago
parent
commit
25bd87aa3a
  1. 40
      ILSpy/TreeNodes/AssemblyListTreeNode.cs

40
ILSpy/TreeNodes/AssemblyListTreeNode.cs

@ -1,14 +1,14 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team // Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy of this // Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software // software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge, // without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions: // to whom the Software is furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in all copies or // The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software. // substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
@ -17,8 +17,10 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
@ -98,11 +100,12 @@ namespace ICSharpCode.ILSpy.TreeNodes
files = e.Data.GetData(DataFormats.FileDrop) as string[]; files = e.Data.GetData(DataFormats.FileDrop) as string[];
if (files != null) { if (files != null) {
lock (assemblyList.assemblies) { lock (assemblyList.assemblies) {
var assemblies = (from file in files var assemblies = files
where file != null .Where(file => file != null)
select assemblyList.OpenAssembly(file) into node .SelectMany(file => OpenAssembly(assemblyList, file))
where node != null .Where(asm => asm != null)
select node).Distinct().ToList(); .Distinct()
.ToArray();
foreach (LoadedAssembly asm in assemblies) { foreach (LoadedAssembly asm in assemblies) {
int nodeIndex = assemblyList.assemblies.IndexOf(asm); int nodeIndex = assemblyList.assemblies.IndexOf(asm);
if (nodeIndex < index) if (nodeIndex < index)
@ -117,6 +120,25 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
private IEnumerable<LoadedAssembly> OpenAssembly(AssemblyList assemblyList, string file)
{
if (file.EndsWith(".nupkg")) {
LoadedNugetPackage package = new LoadedNugetPackage(file);
var selectionDialog = new NugetPackageBrowserDialog(package);
selectionDialog.Owner = Application.Current.MainWindow;
if (selectionDialog.ShowDialog() != true)
yield break;
foreach (var entry in selectionDialog.SelectedItems) {
var nugetAsm = assemblyList.OpenAssembly("nupkg://" + file + ";" + entry.Name, entry.Stream, true);
if (nugetAsm != null) {
yield return nugetAsm;
}
}
yield break;
}
yield return assemblyList.OpenAssembly(file);
}
public Action<SharpTreeNode> Select = delegate { }; public Action<SharpTreeNode> Select = delegate { };
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
@ -168,7 +190,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
return null; return null;
} }
public AssemblyTreeNode FindAssemblyNode(AssemblyDefinition asm) public AssemblyTreeNode FindAssemblyNode(AssemblyDefinition asm)
{ {
if (asm == null) if (asm == null)

Loading…
Cancel
Save