예제 #1
0
        /// <summary>
        /// Delegate to target object handling of equals method.
        /// </summary>
        /// <param name="obj">The object to compare with the current target object</param>
        /// <returns>true if the specified Object is equal to the current target object; otherwise, false</returns>
        public override bool Equals(object obj)
        {
            bool         equals      = false;
            object       target      = m_targetSource.GetTarget();
            AdvisedProxy otherProxy  = obj as AdvisedProxy;
            object       otherTarget = null;

            if (otherProxy != null)
            {
                otherTarget = otherProxy.m_targetSource.GetTarget();
                if (target == null)
                {
                    equals = (otherTarget == null);
                }
                else
                {
                    equals = target.Equals(otherTarget);
                }
            }
            else if (target == null)
            {
                equals = (obj == null);
            }
            else
            {
                equals = target.Equals(obj);
            }
            m_targetSource.ReleaseTarget(target);
            if (otherProxy != null)
            {
                otherProxy.m_targetSource.ReleaseTarget(otherTarget);
            }
            return(equals);
        }
예제 #2
0
        /// <summary>
        /// Delegate to target object handling of equals method.
        /// </summary>
        /// <param name="obj">The object to compare with the current target object</param>
        /// <returns>true if the specified Object is equal to the current target object; otherwise, false</returns>
        public override bool Equals(object obj)
        {
            AdvisedProxy otherProxy = obj as AdvisedProxy;

            if (otherProxy != null)
            {
                using (m_targetSourceWrapper)
                    using (otherProxy.m_targetSourceWrapper)
                    {
                        object target      = m_targetSourceWrapper.GetTarget();
                        object otherTarget = otherProxy.m_targetSourceWrapper.GetTarget();
                        if (target == null)
                        {
                            return(otherTarget == null);
                        }
                        return(target.Equals(otherTarget));
                    }
            }

            using (m_targetSourceWrapper)
            {
                object target = m_targetSourceWrapper.GetTarget();
                if (target == null)
                {
                    return(obj == null);
                }
                return(target.Equals(obj));
            }
        }