public bool AddEntry(ITableEntry entry) { ICountedTableEntry countedEntry = entry as ICountedTableEntry; if (countedEntry != null && this.countedEntries.TryGetValue(countedEntry, out ICountedTableEntry existingCountedEntry)) { existingCountedEntry.AddCount(); int i = this.entries.IndexOf(entry); Debug.Assert(i != -1, $"{nameof(this.countedEntries)} has extra entries in it."); if (i != -1) { // Tell the table that this entry has been updated this.entries[i] = existingCountedEntry; } return(false); } else { if (countedEntry != null) { this.countedEntries.Add(countedEntry); } this.entries.Add(entry); return(true); } }
public bool AddEntry(ITableEntry entry) { ICountedTableEntry countedEntry = entry as ICountedTableEntry; if (countedEntry != null && this.countedEntries.TryGetValue(countedEntry, out ICountedTableEntry existingCountedEntry)) { existingCountedEntry.AddCount(); int i = this.entries.IndexOf(entry); Debug.Assert(i != -1, $"{nameof(this.countedEntries)} has extra entries in it."); if (i != -1) { // Tell the table that this entry has been updated this.entries[i] = existingCountedEntry; } return(false); } else { if (countedEntry != null) { this.countedEntries.Add(countedEntry); } this.entries.Add(entry); if (entry is IWpfTableEntry wpfEntry && wpfEntry.TryCreateStringContent(ColumnNames.Code, false, false, out string code) && !string.IsNullOrEmpty(code)) { this.Telemetry.TrackEvent(Constants.EventNewEntry, new Dictionary <string, object>() { { Constants.PropertyErrorCode, code }, }); } return(true); } }