예제 #1
0
        public override bool Equals(object other)
        {
            if (!(other is BaseException))
            {
                return(false);
            }
            BaseException exception = (BaseException)other;

            // Check the inner exception.

            System.Exception innerException = InnerException;
            if (innerException == null)
            {
                if (exception.InnerException != null)
                {
                    return(false);
                }
            }
            else
            {
                if (exception.InnerException == null)
                {
                    return(false);
                }

                if (innerException is BaseException)
                {
                    if (!(exception.InnerException is BaseException))
                    {
                        return(false);
                    }
                    else if (!innerException.Equals(exception.InnerException))
                    {
                        return(false);
                    }
                }
                else
                {
                    // Can't do much more then check the properties themselves.

                    if (innerException.Message != exception.InnerException.Message ||
                        innerException.Source != exception.InnerException.Source ||
                        innerException.StackTrace != exception.InnerException.StackTrace ||
                        !object.Equals(innerException.InnerException, exception.InnerException.InnerException))
                    {
                        return(false);
                    }
                }
            }

            return(Source == exception.Source &&
                   StackTrace == exception.StackTrace &&
                   m_method == exception.m_method &&
                   m_time == exception.m_time &&
                   m_details.Equals(exception.m_details));
        }