/// <summary> /// Add new duplication entry (Tuple of log entry (original) and collection of log entries (duplications)) /// </summary> /// <param name="entry"></param> /// <param name="timeOfOriginal"></param> private void AddNewDuplicationEntry(Log9KEntry entry, Log9KTime timeOfOriginal) { if (!CheckForDuplicationMethods()) { return; } int duplicationKey = KeyForDuplicationDictionary(entry); Log9KUtil.InvokeInUiThread(() => { if (DuplicationsDictionary.ContainsKey(duplicationKey)) { return; } ObservableCollection <DuplicationLeaf> times = new ObservableCollection <DuplicationLeaf>(); if (timeOfOriginal == null) { times = new ObservableCollection <Tuple <Log9KTime, uint> > { new DuplicationLeaf(entry.Time, entry.ID) }; } DuplicationNode de = new DuplicationNode( entry, times ); DuplicationsDictionary.Add(duplicationKey, de); }); }
/// <summary> /// Add duplicate to existing entry, for adding new duplication entry use AddNewDuplicationEntry /// </summary> /// <param name="entry"></param> private void AddToDuplicationEntry(Log9KEntry entry) { if (!CheckForDuplicationMethods()) { return; } int duplicationKey = KeyForDuplicationDictionary(entry); Log9KUtil.InvokeInUiThread(() => { DuplicationNode duplicationEntry = DuplicationsDictionary[duplicationKey]; duplicationEntry.Item2.Add(new DuplicationLeaf(entry.Time, entry.ID)); if (duplicationEntry.Item2.Count == 2) { DuplicationsCollection.Add(duplicationEntry); } }); }
/// <summary> /// Adds entry to duplications dictionary: /// <para>if it is not met before creates new DuplicationEntry, /// else adds time of given entry in list of existing DuplicationEntry</para> /// </summary> /// <param name="entry"></param> private void AddToDuplicationsDictionary(Log9KEntry entry) { if (entry.Level == Levels.SECONDARY) { return; } DuplicationNode duplicationEntry = LookupForDuplication(entry); if (duplicationEntry == null) { AddNewDuplicationEntry(entry, null); } else { entry.IsDuplicate = true; duplicationEntry.Item1.IsDuplicate = true; AddToDuplicationEntry(entry); } }