This commit is contained in:
Lluis Sanchez 2013-07-16 21:39:40 +02:00
Родитель 3dcdc3af42
Коммит f1363fb747
1 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -41,10 +41,19 @@ namespace Mono.Addins.CecilReflector
{ {
IAssemblyLocator locator; IAssemblyLocator locator;
Hashtable cachedAssemblies = new Hashtable (); Hashtable cachedAssemblies = new Hashtable ();
DefaultAssemblyResolver defaultAssemblyResolver;
public void Initialize (IAssemblyLocator locator) public void Initialize (IAssemblyLocator locator)
{ {
this.locator = locator; this.locator = locator;
defaultAssemblyResolver = new DefaultAssemblyResolver ();
defaultAssemblyResolver.ResolveFailure += delegate (object sender, AssemblyNameReference reference) {
var file = locator.GetAssemblyLocation (reference.FullName);
if (file != null)
return LoadAssembly (file, true);
else
return null;
};
} }
public object[] GetCustomAttributes (object obj, Type type, bool inherit) public object[] GetCustomAttributes (object obj, Type type, bool inherit)
@ -286,7 +295,9 @@ namespace Mono.Addins.CecilReflector
AssemblyDefinition adef = (AssemblyDefinition) cachedAssemblies [file]; AssemblyDefinition adef = (AssemblyDefinition) cachedAssemblies [file];
if (adef != null) if (adef != null)
return adef; return adef;
adef = AssemblyDefinition.ReadAssembly (file); var rp = new ReaderParameters (ReadingMode.Deferred);
rp.AssemblyResolver = defaultAssemblyResolver;
adef = AssemblyDefinition.ReadAssembly (file, rp);
if (adef != null && cache) if (adef != null && cache)
cachedAssemblies [file] = adef; cachedAssemblies [file] = adef;
return adef; return adef;