diff --git a/ILSpy/App.xaml.cs b/ILSpy/App.xaml.cs
index 39af423cb..6004486c9 100644
--- a/ILSpy/App.xaml.cs
+++ b/ILSpy/App.xaml.cs
@@ -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
{
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;
diff --git a/ILSpy/CSharpLanguage.cs b/ILSpy/CSharpLanguage.cs
index 9966b9b12..0192c43d3 100644
--- a/ILSpy/CSharpLanguage.cs
+++ b/ILSpy/CSharpLanguage.cs
@@ -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
///
/// Decompiler logic for C#.
///
+ [Export(typeof(Language))]
public class CSharpLanguage : Language
{
string name = "C#";
diff --git a/ILSpy/GacInterop.cs b/ILSpy/GacInterop.cs
index 4a0863d3c..9ab255f59 100644
--- a/ILSpy/GacInterop.cs
+++ b/ILSpy/GacInterop.cs
@@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy
///
/// Interop with the .NET GAC.
///
- public static class GacInterop
+ static class GacInterop
{
///
/// Gets the names of all assemblies in the GAC.
diff --git a/ILSpy/GuessFileType.cs b/ILSpy/GuessFileType.cs
index b27597337..72a38f210 100644
--- a/ILSpy/GuessFileType.cs
+++ b/ILSpy/GuessFileType.cs
@@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy
///
/// Static methods for determining the type of a file.
///
- public static class GuessFileType
+ static class GuessFileType
{
public static FileType DetectFileType(Stream stream)
{
@@ -120,7 +120,7 @@ namespace ICSharpCode.ILSpy
}
}
- public enum FileType
+ enum FileType
{
Binary,
Text,
diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj
index 8b3406c3a..8ed9cd687 100644
--- a/ILSpy/ILSpy.csproj
+++ b/ILSpy/ILSpy.csproj
@@ -55,6 +55,9 @@
3.0
+
+ 4.0
+
3.5
diff --git a/ILSpy/Language.cs b/ILSpy/Language.cs
index 3bce054af..238e87e63 100644
--- a/ILSpy/Language.cs
+++ b/ILSpy/Language.cs
@@ -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
public static class Languages
{
+ static ReadOnlyCollection allLanguages;
+
///
/// A list of all languages.
///
- public static readonly ReadOnlyCollection AllLanguages = new List(
- new Language[] {
- new CSharpLanguage(),
- new ILLanguage(true)
+ public static ReadOnlyCollection AllLanguages {
+ get {
+ return allLanguages;
}
+ }
+
+
+ internal static void Initialize(CompositionContainer composition)
+ {
+ List languages = new List();
+ languages.AddRange(composition.GetExportedValues());
+ 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();
+ }
///
/// Gets a language using its name.
diff --git a/ILSpy/NavigationHistory.cs b/ILSpy/NavigationHistory.cs
index 521780af1..f15cfa732 100644
--- a/ILSpy/NavigationHistory.cs
+++ b/ILSpy/NavigationHistory.cs
@@ -10,7 +10,7 @@ namespace ICSharpCode.ILSpy
///
/// Stores the navigation history.
///
- public class NavigationHistory
+ sealed class NavigationHistory
{
List back = new List();
List forward = new List();