//--------------------------------------------------------------------------------------------------

        public static ScriptInstance LoadScriptFromFile(string filename, ScriptContext contextInstance, bool forceReload = false)
        {
            if (!File.Exists(filename))
            {
                Messages.Error("Script file does not exist: " + filename);
            }

            ScriptInstance scriptInstance;

            if (!forceReload)
            {
                scriptInstance = ScriptCache.Find(filename);
                if (scriptInstance != null)
                {
                    return(scriptInstance);
                }
            }

            scriptInstance = new ScriptInstance(filename, contextInstance);
            if (ScriptCompiler.Compile(scriptInstance))
            {
                return(scriptInstance);
            }
            return(null);
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        internal static bool Compile(ScriptInstance scriptInstance)
        {
            var compiler = new ScriptCompiler(scriptInstance);

            if (!compiler._Compile())
            {
                return(false);
            }

            ScriptCache.Add(scriptInstance, compiler._FileList);

            return(true);
        }
Exemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        internal static void Add(ScriptInstance scriptInstance, List <string> fileList)
        {
            var entry = new CachedScript
            {
                Instance  = scriptInstance,
                FileInfos = new CachedScriptFileInfo[fileList.Count],
            };

            for (var i = 0; i < fileList.Count; i++)
            {
                var fi   = new FileInfo(fileList[i]);
                var info = new CachedScriptFileInfo()
                {
                    FileName      = fileList[i],
                    Length        = fi.Length,
                    LastWriteTime = fi.LastWriteTimeUtc
                };
                entry.FileInfos[i] = info;
            }

            _CachedScripts[scriptInstance.Path] = entry;
        }
Exemplo n.º 4
0
        //--------------------------------------------------------------------------------------------------

        ScriptCompiler(ScriptInstance scriptInstance)
        {
            _ScriptInstance = scriptInstance;
        }