Ejemplo n.º 1
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         return((ProtectedRange.GetHashCode() * 397) ^ HandlerRange.GetHashCode());
     }
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public int CompareTo(ExceptionHandlerRange other)
        {
            // Most common shortcut: If the protected range is equal, we just sort by handler start.
            if (ProtectedRange == other.ProtectedRange)
            {
                return(HandlerRange.Start.CompareTo(other.HandlerRange.Start));
            }

            // Check if current EH encloses the other, and if so, order the current EH before the other.
            if (ProtectedRange.Contains(other.ProtectedRange))
            {
                return(-1);
            }
            if (other.ProtectedRange.Contains(ProtectedRange))
            {
                return(1);
            }

            if (HandlerRange.Contains(other.HandlerRange))
            {
                return(-1);
            }
            if (other.HandlerRange.Contains(HandlerRange))
            {
                return(1);
            }

            // EH is not overlapping in any way, just order by start offset.
            return(ProtectedRange.Start.CompareTo(other.ProtectedRange.Start));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determines whether two exception handlers are considered equal.
 /// </summary>
 /// <param name="other">The other exception handler.</param>
 /// <returns><c>true</c> if the handler is equal, <c>false</c> otherwise.</returns>
 public bool Equals(ExceptionHandlerRange other) =>
 ProtectedRange.Equals(other.ProtectedRange) && HandlerRange.Equals(other.HandlerRange);