System.ComponentModel.PropertyDescriptor.Equals C# (CSharp) Method

Equals() public method

Compares this to another to see if they are equivalent. NOTE: If you make a change here, you likely need to change GetHashCode() as well.

public Equals ( object obj ) : bool
obj object
return bool
        public override bool Equals(object obj)
        {
            try
            {
                if (obj == this)
                {
                    return true;
                }

                if (obj == null)
                {
                    return false;
                }

                // Assume that 90% of the time we will only do a .Equals(...) for
                // propertydescriptor vs. propertydescriptor... avoid the overhead
                // of an instanceof call.
                PropertyDescriptor pd = obj as PropertyDescriptor;

                if (pd != null && pd.NameHashCode == NameHashCode
                    && pd.PropertyType == PropertyType
                    && pd.Name.Equals(Name))
                {
                    return true;
                }
            }
            catch { }

            return false;
        }

Usage Example

Example #1
0
        // Determine if two objects are equal.
        public override bool Equals(Object obj)
        {
            ExtenderProvidedPropertyAttribute other;

            other = (obj as ExtenderProvidedPropertyAttribute);
            if (other != null)
            {
                if (extenderProperty != null)
                {
                    if (!extenderProperty.Equals(other.extenderProperty))
                    {
                        return(false);
                    }
                }
                else if (other.extenderProperty != null)
                {
                    return(false);
                }
                if (provider != null)
                {
                    if (!provider.Equals(other.provider))
                    {
                        return(false);
                    }
                }
                else if (other.provider != null)
                {
                    return(false);
                }
                if (receiverType != null)
                {
                    if (!receiverType.Equals(other.receiverType))
                    {
                        return(false);
                    }
                }
                else if (other.receiverType != null)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
All Usage Examples Of System.ComponentModel.PropertyDescriptor::Equals