Browse Source

Decompile string resources in .resources TreeNodes and show them in a table.

pull/226/head
Ronny Klier 14 years ago
parent
commit
a07bea82ea
  1. 20
      ILSpy/Controls/ResourceStringTable.xaml
  2. 36
      ILSpy/Controls/ResourceStringTable.xaml.cs
  3. 6
      ILSpy/ILSpy.csproj
  4. 25
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

20
ILSpy/Controls/ResourceStringTable.xaml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.ILSpy.Controls.ResourceStringTable" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls">
<ListView
Name="resourceListView">
<ListView.View>
<GridView
AllowsColumnReorder="False">
<GridView.Columns>
<GridViewColumn
Header="Resource id"
DisplayMemberBinding="{Binding Key}" />
<GridViewColumn
Header="Resource value"
DisplayMemberBinding="{Binding Value}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</UserControl>

36
ILSpy/Controls/ResourceStringTable.xaml.cs

@ -0,0 +1,36 @@
/*
* Created by SharpDevelop.
* User: Ronny Klier
* Date: 31.05.2011
* Time: 00:13
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.ILSpy.Controls
{
/// <summary>
/// Interaction logic for ResourceStringTable.xaml
/// </summary>
public partial class ResourceStringTable : UserControl
{
public ResourceStringTable(IEnumerable strings)
{
InitializeComponent();
// set size to fit decompiler window
// TODO: there should be a more transparent way to do this
MaxWidth = MainWindow.Instance.mainPane.ActualWidth-20;
MaxHeight = MainWindow.Instance.mainPane.ActualHeight-100;
resourceListView.ItemsSource = strings;
}
}
}

6
ILSpy/ILSpy.csproj

@ -68,6 +68,7 @@
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
@ -101,6 +102,10 @@
<Compile Include="ConnectMethodDecompiler.cs" />
<Compile Include="Controls\DockedPane.cs" />
<Compile Include="Commands\DecompileAllCommand.cs" />
<Compile Include="Controls\ResourceStringTable.xaml.cs">
<DependentUpon>ResourceStringTable.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="DecompilerSettingsPanel.xaml.cs">
<DependentUpon>DecompilerSettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
@ -246,6 +251,7 @@
<EmbeddedResource Include="TextView\ILAsm-Mode.xshd" />
</ItemGroup>
<ItemGroup>
<Page Include="Controls\ResourceStringTable.xaml" />
<Page Include="Controls\SearchBoxStyle.xaml">
<DependentUpon>SearchBox.cs</DependentUpon>
</Page>

25
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -18,10 +18,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Resources;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Controls;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.TreeNodes
@ -46,6 +51,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
sealed class ResourcesFileTreeNode : ResourceTreeNode
{
ICollection<KeyValuePair<string, string>> filteredEntries = new ObservableCollection<KeyValuePair<string, string>>();
public ResourcesFileTreeNode(EmbeddedResource er)
: base(er)
{
@ -75,8 +82,26 @@ namespace ICSharpCode.ILSpy.TreeNodes
Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), (Stream)entry.Value));
else if (entry.Value is byte[])
Children.Add(ResourceEntryNode.Create(entry.Key.ToString(), new MemoryStream((byte[])entry.Value)));
else if (entry.Value is String)
filteredEntries.Add(new KeyValuePair<string, string>(entry.Key.ToString(), (string)entry.Value));
}
}
}
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
base.Decompile(language, output, options);
if (null == filteredEntries)
return;
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
return new ResourceStringTable(filteredEntries);
}
);
}
output.WriteLine();
}
}
}
Loading…
Cancel
Save