/// <summary> /// This checks "deeply" for the specified item. /// That is, it tried first to find it in the top-level dictionary, /// then it checks each of the parents, then it checks defaults if they exist. /// If a "shallow" check is required, call "Shallow().Contains()" instead. /// </summary> /// <param name="item">The KeyValuePair of interest.</param> /// <returns>A boolean value indicating it the item was found.</returns> public bool Contains(KeyValuePair <TKey, TValue> item) { lock (_syncRoot) { // if the item exists at the top level, then we're done if (_localEntries.Contains(item)) { return(true); } // it doesn't really matter in what order the parents are searched (we either find it or not) if (Parents.Any(parent => (parent as ICollection <KeyValuePair <TKey, TValue> >).Contains(item))) { return(true); } // lastly we need to check Defaults return(LocalDefaults != null && (LocalDefaults as ICollection <KeyValuePair <TKey, TValue> >).Contains(item)); } }