Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public virtual string GetCacheKey(ModuleRequest moduleRequest)
 {
     return(moduleRequest.AbsolutePath);
 }
Esempio n. 4
0
 public abstract bool TryGetModule(ModuleRequest moduleRequest, out Module result);