Browse Source

Add plugin support using MEF.

pull/70/head
Daniel Grunwald 15 years ago
parent
commit
c23e29e75c
  1. 8
      ILSpy/App.xaml.cs
  2. 3
      ILSpy/CSharpLanguage.cs
  3. 2
      ILSpy/GacInterop.cs
  4. 4
      ILSpy/GuessFileType.cs
  5. 3
      ILSpy/ILSpy.csproj
  6. 25
      ILSpy/Language.cs
  7. 2
      ILSpy/NavigationHistory.cs

8
ILSpy/App.xaml.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel.Composition.Hosting;
using System.Diagnostics;
using System.Threading;
using System.Windows;
@ -35,6 +36,13 @@ namespace ICSharpCode.ILSpy @@ -35,6 +36,13 @@ namespace ICSharpCode.ILSpy
{
InitializeComponent();
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly));
catalog.Catalogs.Add(new DirectoryCatalog(".", "*.Plugin.dll"));
var container = new CompositionContainer(catalog);
Languages.Initialize(container);
if (!Debugger.IsAttached) {
AppDomain.CurrentDomain.UnhandledException += ShowErrorBox;
Dispatcher.CurrentDispatcher.UnhandledException += Dispatcher_UnhandledException;

3
ILSpy/CSharpLanguage.cs

@ -19,13 +19,13 @@ @@ -19,13 +19,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Resources;
using System.Threading.Tasks;
using System.Xaml;
using System.Xml;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.Decompiler.Ast.Transforms;
@ -37,6 +37,7 @@ namespace ICSharpCode.ILSpy @@ -37,6 +37,7 @@ namespace ICSharpCode.ILSpy
/// <summary>
/// Decompiler logic for C#.
/// </summary>
[Export(typeof(Language))]
public class CSharpLanguage : Language
{
string name = "C#";

2
ILSpy/GacInterop.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy
/// <summary>
/// Interop with the .NET GAC.
/// </summary>
public static class GacInterop
static class GacInterop
{
/// <summary>
/// Gets the names of all assemblies in the GAC.

4
ILSpy/GuessFileType.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy @@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy
/// <summary>
/// Static methods for determining the type of a file.
/// </summary>
public static class GuessFileType
static class GuessFileType
{
public static FileType DetectFileType(Stream stream)
{
@ -120,7 +120,7 @@ namespace ICSharpCode.ILSpy @@ -120,7 +120,7 @@ namespace ICSharpCode.ILSpy
}
}
public enum FileType
enum FileType
{
Binary,
Text,

3
ILSpy/ILSpy.csproj

@ -55,6 +55,9 @@ @@ -55,6 +55,9 @@
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

25
ILSpy/Language.cs

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using ICSharpCode.Decompiler;
using Mono.Cecil;
@ -121,19 +122,29 @@ namespace ICSharpCode.ILSpy @@ -121,19 +122,29 @@ namespace ICSharpCode.ILSpy
public static class Languages
{
static ReadOnlyCollection<Language> allLanguages;
/// <summary>
/// A list of all languages.
/// </summary>
public static readonly ReadOnlyCollection<Language> AllLanguages = new List<Language>(
new Language[] {
new CSharpLanguage(),
new ILLanguage(true)
public static ReadOnlyCollection<Language> AllLanguages {
get {
return allLanguages;
}
}
internal static void Initialize(CompositionContainer composition)
{
List<Language> languages = new List<Language>();
languages.AddRange(composition.GetExportedValues<Language>());
languages.Add(new ILLanguage(true));
#if DEBUG
.Concat(ILAstLanguage.GetDebugLanguages())
.Concat(CSharpLanguage.GetDebugLanguages())
languages.AddRange(ILAstLanguage.GetDebugLanguages());
languages.AddRange(CSharpLanguage.GetDebugLanguages());
#endif
).AsReadOnly();
allLanguages = languages.AsReadOnly();
}
/// <summary>
/// Gets a language using its name.

2
ILSpy/NavigationHistory.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.ILSpy @@ -10,7 +10,7 @@ namespace ICSharpCode.ILSpy
/// <summary>
/// Stores the navigation history.
/// </summary>
public class NavigationHistory
sealed class NavigationHistory
{
List<SharpTreeNode> back = new List<SharpTreeNode>();
List<SharpTreeNode> forward = new List<SharpTreeNode>();

Loading…
Cancel
Save