|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using System.IO;
using Mef.Extended.Tools.Collections;
namespace Mef.Extended.Tools.Reflection
{
public class AssemblyResolver
{
public AssemblyResolver(params Assembly[] assemblies) : this(() => assemblies) { }
public AssemblyResolver(Func<Assembly[]> getList)
{
Assemblies = new AssemblyList(getList());
}
public AssemblyResolver(Func<string, bool> searchFilter = null)
{
Assemblies = new AssemblyList(GetAssemblies(searchFilter));
}
public AssemblyList Assemblies { get; set; }
public static Assembly[] GetReferencedAssemblies()
{
return AppDomain.CurrentDomain.GetAssemblies();
}
public Assembly[] GetAssemblies([Optional]Func<string, bool> searchFilter)
{
var assemblies = Directory.GetFileSystemEntries(AppDomain.CurrentDomain.BaseDirectory, "*.dll", SearchOption.AllDirectories);
var currentAssemblies = searchFilter == null ? assemblies : assemblies.Where(searchFilter).ToArray();
return currentAssemblies.Select(Assembly.LoadFrom).Union(new[] { Assembly.GetExecutingAssembly() }).ToArray();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Bsc (Hons) Business Information Systems.
MCTS: Web Applications Development with Microsoft .NET Framework 4
MCTS: Windows Communication Foundation Development with Microsoft .NET Framework 4
MCTS: Accessing Data with Microsoft .NET Framework 4
Microsoft Certified Professional Developer Certification.