Esempio n. 1
0
 /// <summary>
 /// Returns a hash code for the specified object of the type indicated by <see cref="Type"/>
 /// </summary>
 /// <param name="obj">The obect for which a hash code is to be returned</param>
 /// <returns>A hash code for the specified object</returns>
 public int GetHashCode(object obj) => getHashCode.Invoke(equalityComparer, obj) is int hashCode ? hashCode : throw new Exception("Getting hash code failed");
Esempio n. 2
0
 /// <summary>
 /// Performs a case-sensitive comparison of two objects of the type indicated by <see cref="Type"/> and returns a value indicating whether one is less than, equal to, or greater than the other
 /// </summary>
 /// <param name="x">The first object to compare</param>
 /// <param name="y">The second object to compare</param>
 /// <returns>
 /// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>, as shown in the following table:
 /// <table>
 ///     <tr>
 ///         <th>Value</th>
 ///         <th>Meaning</th>
 ///     </tr>
 ///     <tr>
 ///         <td>Less than zero</td>
 ///         <td><paramref name="x"/> is less than <paramref name="y"/></td>
 ///     </tr>
 ///     <tr>
 ///         <td>Zero</td>
 ///         <td><paramref name="x"/> equals <paramref name="y"/></td>
 ///     </tr>
 ///     <tr>
 ///         <td>Less than zero</td>
 ///         <td><paramref name="x"/> is greater than <paramref name="y"/></td>
 ///     </tr>
 /// </table>
 /// </returns>
 public int Compare(object?x, object?y) => compare.Invoke(comparer, x, y) is int comparison ? comparison : throw new Exception("Comparison failed");
Esempio n. 3
0
 /// <summary>
 /// Determines whether the specified objects of the type indicated by <see cref="Type"/> are equal
 /// </summary>
 /// <param name="x">The first object to compare</param>
 /// <param name="y">The second object to compare</param>
 /// <returns><c>true</c> if the specified objects are equal; otherwise, <c>false</c></returns>
 public new bool Equals(object?x, object?y) => equals.Invoke(equalityComparer, x, y) is bool equality ? equality : throw new Exception("Equality test failed");