public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (obj.GetType() != base.GetType()) { return(false); } MemberDescriptor descriptor = (MemberDescriptor)obj; this.FilterAttributesIfNeeded(); descriptor.FilterAttributesIfNeeded(); if (descriptor.nameHash != this.nameHash) { return(false); } if (((descriptor.category == null) != (this.category == null)) || ((this.category != null) && !descriptor.category.Equals(this.category))) { return(false); } if (((descriptor.description == null) != (this.description == null)) || ((this.description != null) && !descriptor.category.Equals(this.description))) { return(false); } if ((descriptor.attributes == null) != (this.attributes == null)) { return(false); } if (this.attributes != null) { if (this.attributes.Length != descriptor.attributes.Length) { return(false); } for (int i = 0; i < this.attributes.Length; i++) { if (!this.attributes[i].Equals(descriptor.attributes[i])) { return(false); } } } return(true); }
/// <summary> /// <para> /// Compares this instance to the specified <see cref='System.ComponentModel.MemberDescriptor'/> to see if they are equivalent. /// NOTE: If you make a change here, you likely need to change GetHashCode() as well. /// </para> /// </summary> public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } MemberDescriptor mdObj = (MemberDescriptor)obj; FilterAttributesIfNeeded(); mdObj.FilterAttributesIfNeeded(); if (mdObj._nameHash != _nameHash) { return(false); } if ((mdObj._category == null) != (_category == null) || (_category != null && !mdObj._category.Equals(_category))) { return(false); } if ((mdObj._description == null) != (_description == null) || (_description != null && !mdObj._description.Equals(_description))) { return(false); } if ((mdObj._attributes == null) != (_attributes == null)) { return(false); } bool sameAttrs = true; if (_attributes != null) { if (_attributes.Length != mdObj._attributes.Length) { return(false); } for (int i = 0; i < _attributes.Length; i++) { if (!_attributes[i].Equals(mdObj._attributes[i])) { sameAttrs = false; break; } } } return(sameAttrs); }
/// <devdoc> /// <para> /// Compares this instance to the specified <see cref='System.ComponentModel.MemberDescriptor'/> to see if they are equivalent. /// NOTE: If you make a change here, you likely need to change GetHashCode() as well. /// </para> /// </devdoc> public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } MemberDescriptor mdObj = (MemberDescriptor)obj; FilterAttributesIfNeeded(); mdObj.FilterAttributesIfNeeded(); if (mdObj.nameHash != nameHash) { return(false); } if ((mdObj.category == null) != (category == null) || (category != null && !mdObj.category.Equals(category))) { return(false); } // VSO 149471 - Technically fixing this could cause a behavior change, so we are // adding a quirk in case anyone is bit by this and needs the old, buggy behavior. if (!LocalAppContextSwitches.MemberDescriptorEqualsReturnsFalseIfEquivalent) { if ((mdObj.description == null) != (description == null) || (description != null && !mdObj.description.Equals(description))) { return(false); } } else { if ((mdObj.description == null) != (description == null) || (description != null && !mdObj.category.Equals(description))) { return(false); } } if ((mdObj.attributes == null) != (attributes == null)) { return(false); } bool sameAttrs = true; if (attributes != null) { if (attributes.Length != mdObj.attributes.Length) { return(false); } for (int i = 0; i < attributes.Length; i++) { if (!attributes[i].Equals(mdObj.attributes[i])) { sameAttrs = false; break; } } } return(sameAttrs); }