public virtual void StartTail(bool save = true, bool stop = true) { serialFileReader = new CallbackFileReader(new ReaderFactory()) { StartCallback = FormInterface.StartCallback, UpdateCallback = FormInterface.UpdateCallback, FinishCallback = FormInterface.FinishCallback, ExceptionCallback = FormInterface.ExceptionCallback, LoadLastLines = FormInterface.LoadLastLinesCallback, Filter = FormInterface.GetFilterCallback }; if (save) { Properties.Settings.Default.LastFile = FormInterface.GetFileNameCallback(); } if (stop && tailThread != null) { StopTail(); } if (tailThread == null) { tailThread = new TailThread(TailWatcherFactory.CreateWatcher(FormInterface.GetFileNameCallback(), serialFileReader, FormInterface.ExceptionCallback)); } FormInterface.ClearDisplayCallback(); var file = FormInterface.GetFileNameCallback(); try { if (string.IsNullOrEmpty(file)) { return; } serialFileReader.EnableQueue(true); tailThread.Start(file); FormInterface.SetStateCallback(true); } catch (Exception ex) { FormInterface.ExceptionCallback(ex); } }
public EventStream() { tail = new TailThread(conf.LogPath(), new AppendTextDelegate(stream.OnNext)); tail.Start(); _logLines = stream.Where(x => Regex.IsMatch(x, LOG_LINE_PATTERN)); _rawPlays = _logLines.Where(x => Regex.IsMatch(x, CARD_PLAY_PATTERN)); _rawDraws = _logLines.Where(x => Regex.IsMatch(x, CARD_DRAW_PATTERN)); _myPlays = _rawPlays .Where(x => Regex.IsMatch(x, "local=True")) .Select(x => Regex.Matches(x, CARD_PLAY_PATTERN)[0].Groups[1].Value); _theirPlays = _rawPlays .Where(x => Regex.IsMatch(x, "local=False")) .Select(x => Regex.Matches(x, CARD_PLAY_PATTERN)[0].Groups[1].Value); _myDraws = _rawDraws.Select(x => Regex.Matches(x, CARD_DRAW_PATTERN)[0].Groups[1].Value); _myCoinDraws = _logLines .Where(x => Regex.IsMatch(x, COIN_DRAW_PATTERN)) .Select(_ => "The Coin"); _myMulligans = _logLines .Where(x => Regex.IsMatch(x, MULLIGAN_PATTERN)) .Select(x => Regex.Matches(x, MULLIGAN_PATTERN)[0].Groups[1].Value); _myDiscards = _logLines .Where(x => Regex.IsMatch(x, DISCARD_PATTERN)) .Select(x => Regex.Matches(x, DISCARD_PATTERN)[0].Groups[1].Value); _myMills = _logLines .Where(x => Regex.IsMatch(x, MILL_PATTERN)) .Select(x => Regex.Matches(x, MILL_PATTERN)[0].Groups[1].Value); _gameOver = _logLines .Where(x => Regex.IsMatch(x, GAME_OVER_PATTERN)) .Select(_ => true); }