/// <summary> /// Run an optional startup list of commands /// </summary> /// <param name="fileName"></param> protected void RunCommandScript(string fileName) { if (m_console == null) { return; } if (File.Exists(fileName)) { m_log.Info("[SERVER BASE]: Running " + fileName); using (StreamReader readFile = File.OpenText(fileName)) { string currentCommand; while ((currentCommand = readFile.ReadLine()) != null) { currentCommand = currentCommand.Trim(); if (!(currentCommand == "" || currentCommand.StartsWith(";") || currentCommand.StartsWith("//") || currentCommand.StartsWith("#"))) { m_log.Info("[SERVER BASE]: Running '" + currentCommand + "'"); m_console.RunCommand(currentCommand); } } } } }
/// <summary> /// Run an optional startup list of commands /// </summary> /// <param name="fileName"></param> public virtual void RunCommandScript(string fileName) { if (File.Exists(fileName)) { m_log.Info("[COMMANDFILE]: Running " + fileName); List <string> commands = new List <string>(); using (StreamReader readFile = File.OpenText(fileName)) { string currentCommand; while ((currentCommand = readFile.ReadLine()) != null) { if (currentCommand != String.Empty) { commands.Add(currentCommand); } } } foreach (string currentCommand in commands) { m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); m_console.RunCommand(currentCommand); } } }