public void AddCollection(SingleTraitValueEventCollection col) { Debug.Assert(Name == col.TraitName, $"Collections should all have the same trait name: {Name} != {col.TraitName}"); var existsInCollection = LineCollections.TryGetValue(col.TraitValue, out var lc); Debug.Assert(!existsInCollection, $"Added collections should not have duplicate trait values: {col.TraitValue.Substring(0, Math.Min(col.TraitValue.Length, 30))}"); LineCollections.Add(col.TraitValue, col); }
public void Merge(TraitValuesCollection Other) { foreach (var OtherLines in Other.Values) { if (LineCollections.TryGetValue(OtherLines.TraitValue, out var ThisLines)) { // LineCollection with this index value already exists, so merge ThisLines.Merge(OtherLines); } else { // LineCollection wit hthis index value didn't exist, so add it diretly LineCollections.Add(OtherLines.TraitValue, OtherLines); } } }
public void AddLine(string TraitValue, LogEntry Line) { var existsInCollection = LineCollections.TryGetValue(TraitValue, out var lc); lc ??= new SingleTraitValueEventCollection() { TraitName = Name, TraitValue = TraitValue, }; lc.Add(Line); if (!existsInCollection) { LineCollections.Add(lc.TraitValue, lc); } }
/// <summary> /// Lines associated with the given index value /// </summary> /// <param name="IndexValue"></param> /// <returns></returns> /// <remarks></remarks> public LogEntryCollection <LogEntry> LinesFromTraitValue(string TraitValue) { LineCollections.TryGetValue(TraitValue, out var lc); return(lc ?? new()); }