/// <summary> /// Add a resolver instance to the resolver list /// </summary> /// <param name="resolver"></param> public void AddImportResolver(IDlrImportResolver resolver) { RemoveSearchPath(GenericImportModule.RESOLVER_PATH_NAME); AddSearchPath(GenericImportModule.RESOLVER_PATH_NAME); this.resolver.Add(resolver); }
/// <summary> /// Find module for importing. If a resolver is set, the current module should be used /// </summary> /// <param name="context"></param> /// <param name="fullname"></param> /// <param name="args"></param> /// <returns>If resolver is not null, this will be returned, else null</returns> public object find_module(CodeContext /*!*/ context, string fullname, params object[] args) { try { // fullname = MakeValidPath(fullname); foreach (var path in paths) { // Find resolver foreach (var resolver in Host.Resolver) { // Always pass slash instead of dot! string _testPath = MakeValidPath(fullname, path); var res = resolver.GetModuleInformation(_testPath.Replace(".", "/")); // If this script could be resolved by some resolver if (res != ResolvedType.None) { this.resolver = resolver; this.resolved_subpath = path; return(this); } } } return(null); } catch (Exception ex) { throw new ImportException("Error in generic importer.", ex); } }
/// <summary> /// Find module for importing. If a resolver is set, the current module should be used /// </summary> /// <param name="context"></param> /// <param name="fullname"></param> /// <param name="args"></param> /// <returns>If resolver is not null, this will be returned, else null</returns> public object find_module(CodeContext/*!*/ context, string fullname, params object[] args) { try { // fullname = MakeValidPath(fullname); foreach (var path in paths) { // Find resolver foreach (var resolver in Host.Resolver) { // Always pass slash instead of dot! string _testPath = MakeValidPath(fullname, path); var res = resolver.GetModuleInformation(_testPath.Replace(".", "/")); // If this script could be resolved by some resolver if (res != ResolvedType.None) { this.resolver = resolver; this.resolved_subpath = path; return this; } } } return null; } catch (Exception ex) { throw new ImportException("Error in generic importer.", ex); } }