Browse Source

Added an option to filter GAC entries by version in addition to name.

pull/112/head
Artur Zgodziski 14 years ago
parent
commit
a2e11b76be
  1. 32
      ILSpy/OpenFromGacDialog.xaml.cs

32
ILSpy/OpenFromGacDialog.xaml.cs

@ -39,6 +39,7 @@ namespace ICSharpCode.ILSpy @@ -39,6 +39,7 @@ namespace ICSharpCode.ILSpy
{
ObservableCollection<GacEntry> gacEntries = new ObservableCollection<GacEntry>();
ObservableCollection<GacEntry> filteredEntries = new ObservableCollection<GacEntry>();
Predicate<GacEntry> filterMethod = _ => true;
volatile bool cancelFetchThread;
public OpenFromGacDialog()
@ -62,6 +63,7 @@ namespace ICSharpCode.ILSpy @@ -62,6 +63,7 @@ namespace ICSharpCode.ILSpy
{
readonly AssemblyNameReference r;
readonly string fileName;
string formattedVersion;
public GacEntry(AssemblyNameReference r, string fileName)
{
@ -85,6 +87,14 @@ namespace ICSharpCode.ILSpy @@ -85,6 +87,14 @@ namespace ICSharpCode.ILSpy
get { return r.Version; }
}
public string FormattedVersion {
get {
if (formattedVersion == null)
formattedVersion = Version.ToString();
return formattedVersion;
}
}
public string Culture {
get { return r.Culture; }
}
@ -132,20 +142,28 @@ namespace ICSharpCode.ILSpy @@ -132,20 +142,28 @@ namespace ICSharpCode.ILSpy
void AddNewEntry(GacEntry entry)
{
gacEntries.Add(entry);
string filter = filterTextBox.Text;
if (string.IsNullOrEmpty(filter) || entry.ShortName.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
if (filterMethod(entry))
filteredEntries.Add(entry);
}
#endregion
void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
string filter = filterTextBox.Text;
filteredEntries.Clear();
foreach (GacEntry entry in gacEntries) {
if (string.IsNullOrEmpty(filter) || entry.ShortName.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0)
filteredEntries.Add(entry);
string filterString = filterTextBox.Text.Trim();
if (filterString.Length == 0)
filterMethod = _ => true;
else {
var elements = filterString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
filterMethod = entry => elements.All(el => Contains(entry.FullName, el) || Contains(entry.FormattedVersion, el));
}
filteredEntries.Clear();
filteredEntries.AddRange(gacEntries.Where(entry => filterMethod(entry)));
}
static bool Contains(string s, string subString)
{
return s.IndexOf(subString, StringComparison.OrdinalIgnoreCase) >= 0;
}
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)

Loading…
Cancel
Save