public void Add(RelationName type, RelationName child, params RelationName[] moreChildren) { if (BackingDictionary.ContainsKey(type)) { throw new ArgumentException($"{type} is already mapped as parent, you have to map all it's children as a single entry"); } BackingDictionary.Add(type, new Children(child, moreChildren)); }
/// <summary>Returns false if the item's key is already present (even if it's for a different item - your GetKeyForItem function should be a bijection). Otherwise returns true after item is added to the collection.</summary> public Task <bool> TryAddAsync([NotNull] TItem item) { return(RunOnSynchronizationContext(() => { var key = GetKeyForItem(item); if (!BackingDictionary.ContainsKey(key)) { InternalAdd(key, item); return true; } return false; })); }
/// <summary> /// Add a new result to the list of results. /// </summary> /// <param name="o"></param> public void Add(object o) { if (BackingDictionary.ContainsKey(o)) { int currentCount = (int)BackingDictionary[o]; BackingDictionary[o] = currentCount + 1; } else { BackingDictionary.Add(o, 1); } ++Count; }
/// <summary> /// <see cref="Dictionary{TKey,TValue}.ContainsKey"/> /// </summary> public bool ContainsKey([NotNull] TKey key) => BackingDictionary.ContainsKey(key);
public bool ContainsKey(TKey key) => BackingDictionary.ContainsKey(Sanitize(key));