public void SynchronizationContext_IsEqualToCopyOfItself() { SynchronizationContext synchronizationContext1 = AsyncContext.Run(() => SynchronizationContext.Current); SynchronizationContext synchronizationContext2 = synchronizationContext1.CreateCopy(); Assert.Equal(synchronizationContext1.GetHashCode(), synchronizationContext2.GetHashCode()); Assert.True(synchronizationContext1.Equals(synchronizationContext2)); Assert.False(synchronizationContext1.Equals(new SynchronizationContext())); }
public static bool AreEqual(this SynchronizationContext synchronizationContext, SynchronizationContext other) { if (synchronizationContext == null) return other == null; if (other == null) return false; if (synchronizationContext.Equals(other)) return true; if (synchronizationContext is ISynchronizeInvoke synchronizeInvoke) return !synchronizeInvoke.InvokeRequired; // HACK TODO return CheckField(synchronizationContext, null, out object d1, out string fieldName) ? CheckField(other, fieldName, out object d2, out _) && object.Equals(d1, d2) : CheckProperty(synchronizationContext, null, out d1, out string propertyName) ? CheckProperty(other, propertyName, out d2, out _) && object.Equals(d1, d2) : false;
public override bool Equals(object obj) { return(context.Equals(obj)); }