jagregory / boolangstudio forked from olsonjeffery/boolangstudio

Boo language integration for Visual Studio 2008

This URL has Read+Write access

boolangstudio / Source / BooLangService / AssemblyHelper.cs
100644 27 lines (23 sloc) 0.717 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Reflection;
using System.Reflection.Emit;
 
namespace BooLangService
{
    public class AssemblyHelper
    {
        public static Assembly FindAssemblyInCurrentAppDomain(string path)
        {
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (assembly is AssemblyBuilder) continue;
                if (assembly.CodeBase != new Uri(path).ToString()) continue;
 
                return assembly;
            }
 
            return null;
        }
 
        public static Assembly FindInCurrentAppDomainOrLoad(string path)
        {
            return FindAssemblyInCurrentAppDomain(path) ?? Assembly.LoadFrom(path);
        }
    }
}