|
|
|
@ -40,55 +40,55 @@ namespace ICSharpCode.ILSpy
@@ -40,55 +40,55 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
ObservableCollection<GacEntry> gacEntries = new ObservableCollection<GacEntry>(); |
|
|
|
|
ObservableCollection<GacEntry> filteredEntries = new ObservableCollection<GacEntry>(); |
|
|
|
|
volatile bool cancelFetchThread; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OpenFromGacDialog() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
listView.ItemsSource = filteredEntries; |
|
|
|
|
SortableGridViewColumn.SetCurrentSortColumn(listView, nameColumn); |
|
|
|
|
SortableGridViewColumn.SetSortDirection(listView, ColumnSortDirection.Ascending); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new Thread(new ThreadStart(FetchGacContents)).Start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnClosing(CancelEventArgs e) |
|
|
|
|
{ |
|
|
|
|
base.OnClosing(e); |
|
|
|
|
cancelFetchThread = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Fetch Gac Contents
|
|
|
|
|
sealed class GacEntry |
|
|
|
|
{ |
|
|
|
|
readonly AssemblyNameReference r; |
|
|
|
|
readonly string fileName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GacEntry(AssemblyNameReference r, string fileName) |
|
|
|
|
{ |
|
|
|
|
this.r = r; |
|
|
|
|
this.fileName = fileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string FullName { |
|
|
|
|
get { return r.FullName; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string ShortName { |
|
|
|
|
get { return r.Name; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string FileName { |
|
|
|
|
get { return fileName; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Version Version { |
|
|
|
|
get { return r.Version; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Culture { |
|
|
|
|
get { return r.Culture; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string PublicKeyToken { |
|
|
|
|
get { |
|
|
|
|
StringBuilder s = new StringBuilder(); |
|
|
|
@ -97,29 +97,38 @@ namespace ICSharpCode.ILSpy
@@ -97,29 +97,38 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
return s.ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() |
|
|
|
|
{ |
|
|
|
|
return r.FullName; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FetchGacContents() |
|
|
|
|
{ |
|
|
|
|
HashSet<string> fullNames = new HashSet<string>(); |
|
|
|
|
foreach (var r in GacInterop.GetGacAssemblyFullNames()) { |
|
|
|
|
UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Visible; pg.IsIndeterminate = true; }); |
|
|
|
|
var list = GacInterop.GetGacAssemblyFullNames().TakeWhile(_ => !cancelFetchThread).ToList(); |
|
|
|
|
UpdateProgressBar(pg => { pg.IsIndeterminate = false; pg.Maximum = list.Count; }); |
|
|
|
|
foreach (var r in list) { |
|
|
|
|
if (cancelFetchThread) |
|
|
|
|
return; |
|
|
|
|
break; |
|
|
|
|
if (fullNames.Add(r.FullName)) { // filter duplicates
|
|
|
|
|
var file = GacInterop.FindAssemblyInNetGac(r); |
|
|
|
|
if (file != null) { |
|
|
|
|
var entry = new GacEntry(r, file); |
|
|
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<GacEntry>(AddNewEntry), entry); |
|
|
|
|
UpdateProgressBar(pg => { pg.Value = pg.Value + 1; AddNewEntry(entry); }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
UpdateProgressBar(pg => { pg.Visibility = System.Windows.Visibility.Hidden; }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UpdateProgressBar(Action<ProgressBar> updateAction) |
|
|
|
|
{ |
|
|
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => updateAction(gacReadingProgressBar))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AddNewEntry(GacEntry entry) |
|
|
|
|
{ |
|
|
|
|
gacEntries.Add(entry); |
|
|
|
@ -128,7 +137,7 @@ namespace ICSharpCode.ILSpy
@@ -128,7 +137,7 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
filteredEntries.Add(entry); |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FilterTextBox_TextChanged(object sender, TextChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
string filter = filterTextBox.Text; |
|
|
|
@ -138,18 +147,18 @@ namespace ICSharpCode.ILSpy
@@ -138,18 +147,18 @@ namespace ICSharpCode.ILSpy
|
|
|
|
|
filteredEntries.Add(entry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
okButton.IsEnabled = listView.SelectedItems.Count > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OKButton_Click(object sender, RoutedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
this.DialogResult = true; |
|
|
|
|
Close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string[] SelectedFileNames { |
|
|
|
|
get { |
|
|
|
|
return listView.SelectedItems.OfType<GacEntry>().Select(e => e.FileName).ToArray(); |
|
|
|
|