internal Module Import(string importArg) { var request = new ModuleRequest(this, importArg, makeAbsolutePath(this, importArg)); Module module = null; for (var i = 0; i < ModuleResolversChain.Count; i++) { if (ModuleResolversChain[i].TryGetModule(request, out module)) { break; } module = null; } if (module == null) { throw new InvalidOperationException("Unable to load module \"" + request.CmdArgument + "\""); } if (module.FilePath == null) { module.FilePath = request.AbsolutePath; } if (module.EvaluationState == ModuleEvaluationState.Default) { module.ModuleResolversChain.AddRange(ModuleResolversChain); module.Run(); } return(module); }
bool IModuleResolver.TryGetModule(ModuleRequest moduleRequest, out Module result) { var cacheKey = GetCacheKey(moduleRequest); if (_modulesCache.TryGetValue(cacheKey, out result)) { return(true); } if (TryGetModule(moduleRequest, out result)) { _modulesCache.Add(cacheKey, result); return(true); } return(false); }
public virtual string GetCacheKey(ModuleRequest moduleRequest) { return(moduleRequest.AbsolutePath); }
public abstract bool TryGetModule(ModuleRequest moduleRequest, out Module result);