private static bool _GetMetaFromLine(ScriptMetaData ret, string line) { line = line.Trim(); // Empty line? We may find more later if (String.IsNullOrEmpty(line)) { return(true); } // Is this a comment? If not, then return false if (!line.StartsWith("//")) { return(false); } // It is a comment string[] keyval = line.Split(Separator, 2, StringSplitOptions.None); keyval[0] = keyval[0].Substring(2, keyval[0].Length - 2).Trim(); keyval[1] = keyval[1].Trim(); // Add it if (!String.IsNullOrEmpty(keyval[0]) && !ret.ContainsKey(keyval[0])) { //m_log.DebugFormat("[DotNetEngine] Script metadata: Key: \"{0}\", Value: \"{1}\".", keyval[0], keyval[1]); ret.Add(keyval[0], keyval[1]); } return(true); }
public static ScriptMetaData Extract(ref string Script) { ScriptMetaData ret = new ScriptMetaData(); if (string.IsNullOrEmpty(Script)) { return(ret); } // Process it line by line string Line = String.Empty; for (int i = 0; i < Script.Length + 1; i++) { // Found a line separator? if (i < Script.Length && Script[i] != LineSeparator[0] && Script[i] != LineSeparator[1]) { // No, not end of line. Add to current line Line += Script[i]; } else { // Extract MetaData from this line. Returns False if not found. if (!_GetMetaFromLine(ret, Line)) { continue; } // Empty for next round Line = String.Empty; } } return(ret); }
public IScriptScheduler FindScheduler(ScriptMetaData scriptMetaData) { string scheduler = "Scheduler"; if (scriptMetaData.ContainsKey("Scheduler")) { scheduler = scriptMetaData["Scheduler"]; } lock (Schedulers) { if (!Schedulers.ContainsKey(scheduler)) { throw new Exception("Requested script scheduler \"" + scheduler + "\" does not exist."); } return(Schedulers[scheduler]); } }
public IScriptCompiler FindCompiler(ScriptMetaData scriptMetaData) { string compiler = "Compiler_LSL"; if (scriptMetaData.ContainsKey("Compiler")) { compiler = scriptMetaData["Compiler"]; } lock (Compilers) { if (!Compilers.ContainsKey(compiler)) { throw new Exception("Requested script compiler \"" + compiler + "\" does not exist."); } return(Compilers[compiler]); } }