|
|
@ -20,6 +20,7 @@ using System; |
|
|
|
using System.IO; |
|
|
|
using System.IO; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.Decompiler; |
|
|
|
using ICSharpCode.Decompiler; |
|
|
|
|
|
|
|
using ICSharpCode.Decompiler.Metadata; |
|
|
|
using ICSharpCode.ILSpy.TextView; |
|
|
|
using ICSharpCode.ILSpy.TextView; |
|
|
|
|
|
|
|
|
|
|
|
using Microsoft.Win32; |
|
|
|
using Microsoft.Win32; |
|
|
@ -32,42 +33,47 @@ namespace ICSharpCode.ILSpy.TreeNodes |
|
|
|
public class ResourceEntryNode : ILSpyTreeNode |
|
|
|
public class ResourceEntryNode : ILSpyTreeNode |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly string key; |
|
|
|
private readonly string key; |
|
|
|
private readonly Stream data; |
|
|
|
private readonly Func<Stream> openStream; |
|
|
|
|
|
|
|
|
|
|
|
public override object Text => this.key; |
|
|
|
public override object Text => this.key; |
|
|
|
|
|
|
|
|
|
|
|
public override object Icon => Images.Resource; |
|
|
|
public override object Icon => Images.Resource; |
|
|
|
|
|
|
|
|
|
|
|
protected Stream Data => data; |
|
|
|
protected Stream OpenStream() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return openStream(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResourceEntryNode(string key, Stream data) |
|
|
|
public ResourceEntryNode(string key, Func<Stream> openStream) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (key == null) |
|
|
|
if (key == null) |
|
|
|
throw new ArgumentNullException(nameof(key)); |
|
|
|
throw new ArgumentNullException(nameof(key)); |
|
|
|
if (data == null) |
|
|
|
if (openStream == null) |
|
|
|
throw new ArgumentNullException(nameof(data)); |
|
|
|
throw new ArgumentNullException(nameof(openStream)); |
|
|
|
this.key = key; |
|
|
|
this.key = key; |
|
|
|
this.data = data; |
|
|
|
this.openStream = openStream; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ILSpyTreeNode Create(string key, object data) |
|
|
|
public static ILSpyTreeNode Create(Resource resource) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ILSpyTreeNode result = null; |
|
|
|
ILSpyTreeNode result = null; |
|
|
|
foreach (var factory in App.ExportProvider.GetExportedValues<IResourceNodeFactory>()) |
|
|
|
foreach (var factory in App.ExportProvider.GetExportedValues<IResourceNodeFactory>()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result = factory.CreateNode(key, data); |
|
|
|
result = factory.CreateNode(resource); |
|
|
|
if (result != null) |
|
|
|
if (result != null) |
|
|
|
return result; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
var streamData = data as Stream; |
|
|
|
return result ?? new ResourceTreeNode(resource); |
|
|
|
if (streamData != null) |
|
|
|
} |
|
|
|
result = new ResourceEntryNode(key, data as Stream); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
public static ILSpyTreeNode Create(string name, byte[] data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Create(new ByteArrayResource(name, data)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
|
|
|
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
using var data = OpenStream(); |
|
|
|
language.WriteCommentLine(output, string.Format("{0} = {1}", key, data)); |
|
|
|
language.WriteCommentLine(output, string.Format("{0} = {1}", key, data)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -77,12 +83,9 @@ namespace ICSharpCode.ILSpy.TreeNodes |
|
|
|
dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(key)); |
|
|
|
dlg.FileName = Path.GetFileName(DecompilerTextView.CleanUpName(key)); |
|
|
|
if (dlg.ShowDialog() == true) |
|
|
|
if (dlg.ShowDialog() == true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var data = this.Data; |
|
|
|
using var data = OpenStream(); |
|
|
|
data.Position = 0; |
|
|
|
using var fs = dlg.OpenFile(); |
|
|
|
using (var fs = dlg.OpenFile()) |
|
|
|
data.CopyTo(fs); |
|
|
|
{ |
|
|
|
|
|
|
|
data.CopyTo(fs); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|