internal LoginCommands ReadQueueFromText(string text, bool global, int optionalWaitTimeMs = -1) { var loginCommands = new LoginCommands(); var settings = (new SettingsFileLoader()).ReadSettingsFromText(text); if (optionalWaitTimeMs != -1) { loginCommands.WaitMillisencds = optionalWaitTimeMs; } else { loginCommands.WaitMillisencds = int.Parse(settings.GetValue("WaitMilliseconds").SingleValue); } int count = -1; if (settings.ContainsKey("CommandCount")) { count = int.Parse(settings.GetValue("CommandCount").SingleValue); } else { count = settings.Count; } for (int i = 0; i < count; ++i) { string cmd = settings.GetValue(string.Format("Command{0}", i)).SingleValue; if (!string.IsNullOrEmpty(cmd)) { log.WriteInfo("cmd: '" + cmd + "'"); } loginCommands.Commands.Enqueue(cmd); } return(loginCommands); }
private static LoginCommands ParseCommandsFromText(string text) { var cmds = new LoginCommands(); foreach (var line in SplitLines(text)) { cmds.Commands.Enqueue(line); } return(cmds); }
internal LoginCommands ReadQueue(bool global) { var loginCommands = new LoginCommands(); string filepath = GetFilepath(global); if (File.Exists(filepath)) { string contents = File.ReadAllText(filepath); var cmds = ReadQueueFromText(contents, global); return(cmds); } return(loginCommands); }
internal void WriteQueue(LoginCommands loginCommands, bool global) { string filepath = GetFilepath(global); using (var file = new StreamWriter(filepath, append: false)) { file.WriteLine("WaitMilliseconds:{0}", loginCommands.GetInternalWaitValue()); file.WriteLine("CommandCount:{0}", loginCommands.Commands.Count); int i = 0; foreach (string cmd in loginCommands.Commands) { file.WriteLine("Command{0}:{1}", i, cmd); ++i; } } }