public override int GetHashCode() { if (_weakReference is object) { return(_hashCode); } return(ReferenceEqualityComparer.GetHashCode(_strongReference)); }
public static ReferenceHolder <T> Weak(T value) { if (value is null) { // Track this as a strong reference so we know 'Equals' should only look at values originally null. return(Strong(value)); } return(new ReferenceHolder <T>(new WeakReference <T>(value), ReferenceEqualityComparer.GetHashCode(value))); }
int IEqualityComparer <object?> .GetHashCode(object?a) { return(ReferenceEqualityComparer.GetHashCode(a)); }