internal bool Contains(object x, object y) { if (!IsReferencePair(x, y)) { return(false); } using (var pair = ReferencePair.GetOrCreate(x, y)) { return(this.pairs.Contains(pair)); } }
internal bool?Add(object x, object y) { if (!IsReferencePair(x, y)) { return(null); } var refCounted = ReferencePair.GetOrCreate(x, y); var added = this.pairs.Add(refCounted); if (!added) { refCounted.Dispose(); } return(added); }
internal static IRefCounted <TValue> GetOrAdd <TKey, TValue>( TKey x, TKey y, MemberSettings settings, ConditionalWeakTable <IRefCounted <ReferencePair>, TValue> .CreateValueCallback creator, out bool created) where TKey : class where TValue : class, IDisposable { var refCounted = ReferencePair.GetOrCreate(x, y); var value = GetOrAdd(refCounted, settings, creator, out created); if (!created) { refCounted.Dispose(); } return(value); }