clean up LoadModAssemblies nonsense a bit

This commit is contained in:
Chris Forbes
2010-03-16 20:03:19 +13:00
parent 3d77bcac69
commit 2e8053257f
2 changed files with 10 additions and 5 deletions

View File

@@ -20,6 +20,8 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
namespace OpenRA
{
@@ -35,5 +37,10 @@ namespace OpenRA
foreach( var ee in e )
fn( ee );
}
public static IEnumerable<string> GetNamespaces(this Assembly a)
{
return a.GetTypes().Select(t => t.Namespace).Distinct().Where(n => n != null);
}
}
}

View File

@@ -71,11 +71,9 @@ namespace OpenRA
internal static void LoadModAssemblies(Manifest m)
{
// All the core namespaces
var asms = new List<Pair<Assembly, string>> (typeof(Game).Assembly.GetTypes()
.Select(a => a.Namespace)
.Distinct()
.Where(b => b != null)
.Select(c => Pair.New(typeof(Game).Assembly, c)));
var asms = typeof(Game).Assembly.GetNamespaces()
.Select(c => Pair.New(typeof(Game).Assembly, c))
.ToList();
// Mod assemblies assumed to contain a single namespace
foreach (var a in m.Assemblies)