public void AddToLog(RpmLogEntryItem[] Entries, bool OutputOnNewLine = true) { try { var entriesAdded = new List <RpmLogEntryItem>(); foreach (var entry in Entries) { if (!_items.OrderByDescending(x => x.CreatedOn).Take(5).Any(x => x.Message == entry.Message)) { entriesAdded.Add(entry); } } if (entriesAdded.Count > 0) { _items.AddRange(entriesAdded); OnLogEntriesAdded?.Invoke(this, new LogEntriesAddedEventArgs(entriesAdded.ToArray(), OutputOnNewLine)); } if (_items.Count >= 500) { this.SaveLog(); } } catch (Exception e) { OnLogOperationFailed?.Invoke(this, new LogHandlerOperationFailedEventArgs(RpmLogOperation.AddToLog, e.Message)); } }
private void Log_OnLogEntriesAdded(object sender, LogEntriesAddedEventArgs e) { OnLogEntriesAdded?.Invoke(sender, e); }