Exemplo n.º 1
0
        /// <summary>
        /// Determines whether the specified objects are equal.
        /// </summary>
        /// <param name="x">The first <see cref="MemberInfo"/> instance to compare.</param>
        /// <param name="y">The second <see cref="MemberInfo"/> instance to compare.</param>
        /// <returns>
        /// <see langword="true"/> if the specified objects are considered equal; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// <para>
        /// <paramref name="x"/> and <paramref name="y"/> are considered equal if x is exactly
        /// equal to y. If not, they are still considered equal if both instances'
        /// <see cref="MemberInfo.DeclaringType"/> and <see cref="MemberInfo.Name"/> properties are
        /// equal.
        /// </para>
        /// </remarks>
        public bool Equals(MemberInfo x, MemberInfo y)
        {
            if ((x == null) && (y == null))
            {
                return(true);
            }

            if (x == null)
            {
                return(false);
            }
            if (y == null)
            {
                return(false);
            }

            if (x.Equals(y))
            {
                return(true);
            }

            if (x.DeclaringType == null)
            {
                return(false);
            }
            if (y.DeclaringType == null)
            {
                return(false);
            }

            return(MemberInfoEqualityComparer.AreTypesRelated(x.DeclaringType, y.DeclaringType) &&
                   x.Name == y.Name);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Evaluates whether a request matches the property or field reserved by this command.
        /// </summary>
        /// <param name="request">The specimen request.</param>
        /// <returns>
        /// <see langword="true"/> if <paramref name="request"/> is is a <see cref="PropertyInfo"/>
        /// or <see cref="FieldInfo"/> that identifies the property or field reserved by this
        /// <see cref="BindingCommand{T, TProperty}"/>; otherwise, <see langword="false"/>.
        /// </returns>
        public bool IsSatisfiedBy(object request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            IEqualityComparer comparer = new MemberInfoEqualityComparer();

            return(comparer.Equals(this.member, request));
        }