public AddSearchDirectoryHelper(IAssemblyResolver assemblyResolver) { // reflection is used because IAssemblyResolver doesn't implement AddSearchDirectory but both DefaultAssemblyResolver and NuGetAssemblyResolver do MethodInfo addSearchDirectory = assemblyResolver.GetType().GetMethod("AddSearchDirectory", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { typeof(string) }, null); if (addSearchDirectory == null) { throw new Exception("Assembly resolver doesn't implement AddSearchDirectory method."); } _addSearchDirectory = (AddSearchDirectoryDelegate)Delegate.CreateDelegate(typeof(AddSearchDirectoryDelegate), assemblyResolver, addSearchDirectory); }
public AddSearchDirectoryHelper(IAssemblyResolver assemblyResolver) { System.Type[] types = new System.Type[] { typeof(string) }; MethodInfo method = assemblyResolver.GetType().GetMethod("AddSearchDirectory", BindingFlags.Public | BindingFlags.Instance, null, types, null); if (method == null) { throw new Exception("Assembly resolver doesn't implement AddSearchDirectory method."); } this._addSearchDirectory = (AddSearchDirectoryDelegate)Delegate.CreateDelegate(typeof(AddSearchDirectoryDelegate), assemblyResolver, method); }
public AddSearchDirectoryHelper(IAssemblyResolver assemblyResolver) { System.Type[] types = new System.Type[] { typeof(string) }; MethodInfo method = assemblyResolver.GetType().GetMethod("AddSearchDirectory", BindingFlags.Public | BindingFlags.Instance, null, types, null); if (method == null) { throw new Exception("Assembly resolver doesn't implement AddSearchDirectory method."); } this._addSearchDirectory = (AddSearchDirectoryDelegate) Delegate.CreateDelegate(typeof(AddSearchDirectoryDelegate), assemblyResolver, method); }