public void ShouldReturnNullAsCurrentForEmptyList() { var iterator = new EntryIterator <LogEntry>(); iterator.SetList(new List <LogEntry>().ToArray()); Assert.That(iterator.Current, Is.Null); }
public IEntryIterator <LogEntry> GetLocator() { var locator = new EntryIterator <LogEntry>(); locator.SetList(_entries.ToArray()); return(locator); }
private async void UpdateLocators() { await Task.Run(() => { var iterator = new EntryIterator <LogEntry>(); iterator.SetList(fastObjectListView.Objects.Cast <LogEntry>().ToArray()); var l = new DbInstallStartLocator(); }); }
public void ShouldIterateProperly() { var list = new List <LogEntry>(); list.Add(new LogEntry() { Message = "1" }); list.Add(new LogEntry() { Message = "2" }); list.Add(new LogEntry() { Message = "3" }); list.Add(new LogEntry() { Message = "4" }); var iterator = new EntryIterator <LogEntry>(); iterator.SetList(list.ToArray()); Assert.That(iterator.Current.Message, Is.EqualTo("1")); iterator.Next(); Assert.That(iterator.Current.Message, Is.EqualTo("2")); iterator.Last(); Assert.That(iterator.Current.Message, Is.EqualTo("4")); iterator.Next(); Assert.That(iterator.Current.Message, Is.EqualTo("4")); iterator.Previous(); Assert.That(iterator.Current.Message, Is.EqualTo("3")); iterator.Reset(); Assert.That(iterator.Current.Message, Is.EqualTo("1")); iterator.Previous(); Assert.That(iterator.Current.Message, Is.EqualTo("1")); }
static void Main(string[] args) { var logConfig = new LogConfiguration <DbInstallLogEntry> { FileLocateConfig = new FileLocateConfig { Directories = new List <string>() { @"C:\Dev\log-examples\dbinstall" }, FileMasks = new List <string>() { @"DBInstall.log(.\d*)?" } }, StartCheckers = new List <IEntryStartChecker>() { new DbInstallEntryStartChecker() }, EntryParsers = new List <IEntryParser <DbInstallLogEntry> >() { new DbInstallEntryParser() }, MessageParsers = new List <IEntryMessageParser <DbInstallLogEntry> > { new DacPacDeployStatusParser() }, Locators = new List <IEntryCollector> { new DacpacSuccessLocator(), new DbInstallStartLocator() } }; var locator = new FileLocator(); var files = locator.Locate(logConfig.FileLocateConfig).ToArray(); files.OrderByDescending(fi => fi.LastWriteTime).ToList().ForEach(f => Console.WriteLine(@"Name: {0}. Created: {1}", f.Name, f.LastWriteTime)); var logFileProcesser = new LogFileProcessor(); foreach (var fileInfo in files) { var entries = logFileProcesser.Process(fileInfo.FullName, logConfig.StartCheckers.ToArray(), logConfig.EntryParsers.ToArray()).Cast <DbInstallLogEntry>().ToArray(); var iterator = new EntryIterator <LogEntry>(); iterator.SetList(entries); foreach (var item in entries) { iterator.SetCurrent(item); logConfig.MessageParsers.ToList().ForEach(p => p.Parse(item)); logConfig.Locators.ToList().ForEach(c => c.Analize(item, iterator)); } Console.WriteLine(@"File {0} has {1} entries. Errors {2}. Dacpack: {3}", fileInfo.Name, entries.Count(), entries.Count(e => e.IsParseError), entries.Count(e => e.IsDacpack)); entries.Where(e => e.DacpackStatus == "SUCCESS").ToList().ForEach(e => Console.WriteLine(e.Message)); } var fileWatcher = new FileSystemWatcher(); fileWatcher.Path = Path.GetDirectoryName(files.First().FullName); fileWatcher.Filter = files.First().Name; fileWatcher.NotifyFilter = NotifyFilters.LastWrite; fileWatcher.EnableRaisingEvents = true; fileWatcher.Changed += (source, e) => { //Console.WriteLine("{0} lines added to the file.", newLines.Count()); }; Console.ReadKey(); }