コード例 #1
0
        public override int GetHashCode()
        {
            if (_weakReference is object)
            {
                return(_hashCode);
            }

            return(ReferenceEqualityComparer.GetHashCode(_strongReference));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
 int IEqualityComparer <object?> .GetHashCode(object?a)
 {
     return(ReferenceEqualityComparer.GetHashCode(a));
 }