Browse Source

Implement Save as .resources and .resx for .resources node

pull/758/merge
Siegfried Pammer 9 years ago
parent
commit
f7a7e962b1
  1. 33
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

33
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -27,6 +27,8 @@ using System.Resources; @@ -27,6 +27,8 @@ using System.Resources;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Controls;
using ICSharpCode.ILSpy.TextView;
using Microsoft.Win32;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
@ -112,6 +114,37 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -112,6 +114,37 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
}
public override bool Save(DecompilerTextView textView)
{
EmbeddedResource er = this.Resource as EmbeddedResource;
if (er != null) {
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = DecompilerTextView.CleanUpName(er.Name);
dlg.Filter = "Resources file (*.resources)|*.resources|Resource XML file|*.resx";
if (dlg.ShowDialog() == true) {
Stream s = er.GetResourceStream();
s.Position = 0;
switch (dlg.FilterIndex) {
case 1:
using (var fs = dlg.OpenFile()) {
s.CopyTo(fs);
}
break;
case 2:
var reader = new ResourceReader(s);
using (var writer = new ResXResourceWriter(dlg.OpenFile())) {
foreach (DictionaryEntry entry in reader) {
writer.AddResource(entry.Key.ToString(), entry.Value);
}
}
break;
}
}
return true;
}
return false;
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
EnsureLazyChildren();

Loading…
Cancel
Save