public sealed override bool Equals(object obj) { if ((obj == null) || !Delegate.InternalEqualTypes(this, obj)) { return(false); } MulticastDelegate d = obj as MulticastDelegate; if (d == null) { return(false); } if (this._invocationCount != IntPtr.Zero) { if (this._invocationList == null) { if (!this.IsUnmanagedFunctionPtr()) { return(base.Equals(obj)); } if (!d.IsUnmanagedFunctionPtr()) { return(false); } if (base._methodPtr != d._methodPtr) { return(false); } if (base.GetUnmanagedCallSite() != d.GetUnmanagedCallSite()) { return(false); } return(true); } if (this._invocationList is Delegate) { return(this._invocationList.Equals(obj)); } return(this.InvocationListEquals(d)); } if (this._invocationList != null) { if (!this._invocationList.Equals(d._invocationList)) { return(false); } return(base.Equals(d)); } if ((d._invocationList == null) && !(d._invocationCount != IntPtr.Zero)) { return(base.Equals(d)); } return((d._invocationList is Delegate) && (d._invocationList as Delegate).Equals(this)); }
public override sealed bool Equals(object obj) { if (obj == null || !Delegate.InternalEqualTypes((object)this, obj)) { return(false); } MulticastDelegate d = obj as MulticastDelegate; if (d == null) { return(false); } if (this._invocationCount != (IntPtr)0) { if (this.InvocationListLogicallyNull()) { if (this.IsUnmanagedFunctionPtr()) { if (!d.IsUnmanagedFunctionPtr()) { return(false); } return(Delegate.CompareUnmanagedFunctionPtrs((Delegate)this, (Delegate)d)); } if (d._invocationList is Delegate) { return(this.Equals(d._invocationList)); } return(base.Equals(obj)); } if (this._invocationList is Delegate) { return(this._invocationList.Equals(obj)); } return(this.InvocationListEquals(d)); } if (!this.InvocationListLogicallyNull()) { if (!this._invocationList.Equals(d._invocationList)) { return(false); } return(base.Equals((object)d)); } if (d._invocationList is Delegate) { return(this.Equals(d._invocationList)); } return(base.Equals((object)d)); }
public sealed override bool Equals(object obj) { if (obj == null || !Delegate.InternalEqualTypes(this, obj)) { return(false); } MulticastDelegate multicastDelegate = obj as MulticastDelegate; if (multicastDelegate == null) { return(false); } if (this._invocationCount != (IntPtr)0) { if (this.InvocationListLogicallyNull()) { if (this.IsUnmanagedFunctionPtr()) { return(multicastDelegate.IsUnmanagedFunctionPtr() && Delegate.CompareUnmanagedFunctionPtrs(this, multicastDelegate)); } if (multicastDelegate._invocationList is Delegate) { return(this.Equals(multicastDelegate._invocationList)); } return(base.Equals(obj)); } else { if (this._invocationList is Delegate) { return(this._invocationList.Equals(obj)); } return(this.InvocationListEquals(multicastDelegate)); } } else { if (!this.InvocationListLogicallyNull()) { return(this._invocationList.Equals(multicastDelegate._invocationList) && base.Equals(multicastDelegate)); } if (multicastDelegate._invocationList is Delegate) { return(this.Equals(multicastDelegate._invocationList)); } return(base.Equals(multicastDelegate)); } }
public sealed override bool Equals(object obj) { if ((obj == null) || !Delegate.InternalEqualTypes(this, obj)) { return(false); } MulticastDelegate delegate2 = obj as MulticastDelegate; if (delegate2 == null) { return(false); } if (this._invocationCount != IntPtr.Zero) { if (this.InvocationListLogicallyNull()) { if (!this.IsUnmanagedFunctionPtr()) { return(base.Equals(obj)); } if (!delegate2.IsUnmanagedFunctionPtr()) { return(false); } return(Delegate.CompareUnmanagedFunctionPtrs(this, delegate2)); } if (this._invocationList is Delegate) { return(this._invocationList.Equals(obj)); } return(this.InvocationListEquals(delegate2)); } if (!this.InvocationListLogicallyNull()) { if (!this._invocationList.Equals(delegate2._invocationList)) { return(false); } return(base.Equals(delegate2)); } if (((delegate2._invocationCount != IntPtr.Zero) || !this.InvocationListLogicallyNull()) && (delegate2._invocationList is Delegate)) { return((delegate2._invocationList as Delegate).Equals(this)); } return(base.Equals(delegate2)); }
[System.Security.SecuritySafeCritical] // auto-generated public override sealed bool Equals(Object obj) { if (obj == null || !InternalEqualTypes(this, obj)) { return(false); } MulticastDelegate d = obj as MulticastDelegate; if (d == null) { return(false); } if (_invocationCount != (IntPtr)0) { // there are 4 kind of delegate kinds that fall into this bucket // 1- Multicast (_invocationList is Object[]) // 2- Secure/Wrapper (_invocationList is Delegate) // 3- Unmanaged FntPtr (_invocationList == null) // 4- Open virtual (_invocationCount == MethodDesc of target, _invocationList == null, LoaderAllocator, or DynamicResolver) if (InvocationListLogicallyNull()) { if (IsUnmanagedFunctionPtr()) { if (!d.IsUnmanagedFunctionPtr()) { return(false); } return(CompareUnmanagedFunctionPtrs(this, d)); } // now we know 'this' is not a special one, so we can work out what the other is if ((d._invocationList as Delegate) != null) { // this is a secure/wrapper delegate so we need to unwrap and check the inner one return(Equals(d._invocationList)); } return(base.Equals(obj)); } else { if ((_invocationList as Delegate) != null) { // this is a secure/wrapper delegate so we need to unwrap and check the inner one return(_invocationList.Equals(obj)); } else { Contract.Assert((_invocationList as Object[]) != null, "empty invocation list on multicast delegate"); return(InvocationListEquals(d)); } } } else { // among the several kind of delegates falling into this bucket one has got a non // empty _invocationList (open static with special sig) // to be equals we need to check that _invocationList matches (both null is fine) // and call the base.Equals() if (!InvocationListLogicallyNull()) { if (!_invocationList.Equals(d._invocationList)) { return(false); } return(base.Equals(d)); } // now we know 'this' is not a special one, so we can work out what the other is if ((d._invocationList as Delegate) != null) { // this is a secure/wrapper delegate so we need to unwrap and check the inner one return(Equals(d._invocationList)); } // now we can call on the base return(base.Equals(d)); } }
// equals returns true IIF the delegate is not null and has the // same target, method and invocation list as this object public sealed override bool Equals([NotNullWhen(true)] object?obj) { if (obj == null) { return(false); } if (object.ReferenceEquals(this, obj)) { return(true); } if (!InternalEqualTypes(this, obj)) { return(false); } // Since this is a MulticastDelegate and we know // the types are the same, obj should also be a // MulticastDelegate Debug.Assert( obj is MulticastDelegate, "Shouldn't have failed here since we already checked the types are the same!" ); MulticastDelegate d = Unsafe.As <MulticastDelegate>(obj); if (_invocationCount != (IntPtr)0) { // there are 4 kind of delegate kinds that fall into this bucket // 1- Multicast (_invocationList is Object[]) // 2- Wrapper (_invocationList is Delegate) // 3- Unmanaged FntPtr (_invocationList == null) // 4- Open virtual (_invocationCount == MethodDesc of target, _invocationList == null, LoaderAllocator, or DynamicResolver) if (InvocationListLogicallyNull()) { if (IsUnmanagedFunctionPtr()) { if (!d.IsUnmanagedFunctionPtr()) { return(false); } return(CompareUnmanagedFunctionPtrs(this, d)); } // now we know 'this' is not a special one, so we can work out what the other is if (d._invocationList is Delegate) { // this is a wrapper delegate so we need to unwrap and check the inner one return(Equals(d._invocationList)); } return(base.Equals(obj)); } else { if (_invocationList is Delegate invocationListDelegate) { // this is a wrapper delegate so we need to unwrap and check the inner one return(invocationListDelegate.Equals(obj)); } else { Debug.Assert( _invocationList is object[], "empty invocation list on multicast delegate" ); return(InvocationListEquals(d)); } } } else { // among the several kind of delegates falling into this bucket one has got a non // empty _invocationList (open static with special sig) // to be equals we need to check that _invocationList matches (both null is fine) // and call the base.Equals() if (!InvocationListLogicallyNull()) { if (!_invocationList !.Equals(d._invocationList)) { return(false); } return(base.Equals(d)); } // now we know 'this' is not a special one, so we can work out what the other is if (d._invocationList is Delegate) { // this is a wrapper delegate so we need to unwrap and check the inner one return(Equals(d._invocationList)); } // now we can call on the base return(base.Equals(d)); } }