private static TypeNode LoadTypeNode(string contract, ModuleNode module) { Identifier contractNamespace = Identifier.For(ParseNamespace(contract)); Identifier contractName = Identifier.For(ParseName(contract)); // filter IMetadataExchange if (contractName.Name.Equals(typeof(IMetadataExchange).Name, StringComparison.OrdinalIgnoreCase)) { return(null); } TypeNode typeNode = module.GetType(contractNamespace, contractName, true); if (typeNode == null) { // try to get the type from the asms in the local directory of the current module typeNode = FileGetType(module, contractNamespace, contractName); } return(typeNode); }
private static TypeNode FileGetType(ModuleNode module, Identifier nameSpace, Identifier name) { foreach (string file in Directory.GetFiles( module.Directory, "*.dll", SearchOption.TopDirectoryOnly)) { if (file != module.Location) { ModuleNode localModule = ModuleNode.GetModule(file, true, false, true); if (localModule != null) { TypeNode typeNode = localModule.GetType(nameSpace, name); if (typeNode != null) { // resolve any assembly reference not loaded (GACed) localModule.AssemblyReferenceResolutionAfterProbingFailed += new ModuleNode.AssemblyReferenceResolver(OnAssemblyReferenceResolutionAfterProbingFailed); return(typeNode); } localModule.Dispose(); } } } return(null); }