public LogSourceSearch(ITaskScheduler taskScheduler, ILogSource logSource, string searchTerm, TimeSpan maximumWaitTime) { if (taskScheduler == null) { throw new ArgumentNullException(nameof(taskScheduler)); } if (logSource == null) { throw new ArgumentNullException(nameof(logSource)); } if (string.IsNullOrEmpty(searchTerm)) { throw new ArgumentException("searchTerm may not be empty"); } _logSource = logSource; _filter = new SubstringFilter(searchTerm, true); _matches = new List <LogMatch>(); _syncRoot = new object(); _listeners = new LogFileSearchListenerCollection(this); _pendingModifications = new ConcurrentQueue <LogSourceModification>(); _scheduler = taskScheduler; const int maximumLineCount = 1000; _maximumWaitTime = maximumWaitTime; _logLinesArray = new LogBufferArray(maximumLineCount, Columns.Index, Columns.RawContent); _matchesBuffer = new List <LogLineMatch>(); _logSource.AddListener(this, _maximumWaitTime, maximumLineCount); _task = _scheduler.StartPeriodic(FilterAllPending, TimeSpan.FromMilliseconds(100), string.Format("Search {0}", logSource)); }
public LogFileSearch(ITaskScheduler taskScheduler, ILogFile logFile, string searchTerm, TimeSpan maximumWaitTime) { if (taskScheduler == null) throw new ArgumentNullException("taskScheduler"); if (logFile == null) throw new ArgumentNullException("logFile"); if (string.IsNullOrEmpty(searchTerm)) throw new ArgumentException("searchTerm may not be empty"); _logFile = logFile; _filter = new SubstringFilter(searchTerm, true); _matches = new List<LogMatch>(); _syncRoot = new object(); _listeners = new LogFileSearchListenerCollection(this); _pendingModifications = new ConcurrentQueue<LogFileSection>(); _scheduler = taskScheduler; const int maximumLineCount = 1000; _maximumWaitTime = maximumWaitTime; _logLinesBuffer = new LogLine[maximumLineCount]; _matchesBuffer = new List<LogLineMatch>(); _logFile.AddListener(this, _maximumWaitTime, maximumLineCount); _task = _scheduler.StartPeriodic(FilterAllPending, TimeSpan.FromMilliseconds(100), string.Format("Search {0}", logFile)); }