Esempio n. 1
0
        private static string Load(string file, string args)
        {
            var response = string.Empty;

            var scriptpath = file;

            if (!Path.IsPathRooted(file))
            {
                scriptpath = Path.Combine(_basePath, file);
            }
            if (!File.Exists(scriptpath))
            {
                Console.WriteLine("ERROR: Could not find the script " + scriptpath);
                return("ERROR");
            }
            var ext = Path.GetExtension(scriptpath);

            IScript script = null;

            switch (ext)
            {
            case ".cs":
                script = new CSScript();
                break;

            case ".js":
                script = new JSScript();
                break;

            case ".py":
                script = new PYScript();
                break;

            default:
                Console.WriteLine("ERROR: Unknown file type");
                return("ERROR");
            }
            try
            {
                script.Load(scriptpath);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: Exception caught trying to load " + scriptpath + " - " + ex.Message);
                return("ERROR");
            }
            var pointer = scriptsPointer++;

            scripts.Add(pointer, script);
            return(pointer.ToString());
        }