Class DelegateEqualityComparer<T>
A custom equality comparer that excepts a delegate to do the comparison operation
Inheritance
Namespace: Umbraco.Cms.Core
Assembly: Umbraco.Core.dll
Syntax
public class DelegateEqualityComparer<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
View SourceDelegateEqualityComparer(Func<T?, T?, bool>, Func<T, int>)
Initializes a new instance of the DelegateEqualityComparer<T> class.
Declaration
public DelegateEqualityComparer(Func<T?, T?, bool> equals, Func<T, int> getHashcode)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, T, bool> | equals | A delegate that determines if two objects are equal. |
| Func<T, int> | getHashcode | A delegate that returns the hash code for an object. |
Methods
View SourceCompareMember<TMember>(Func<T?, TMember>)
Creates a DelegateEqualityComparer<T> that compares objects based on a specific member.
Declaration
public static DelegateEqualityComparer<T> CompareMember<TMember>(Func<T?, TMember> memberExpression) where TMember : IEquatable<TMember>
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, TMember> | memberExpression | A function that extracts the member to compare. |
Returns
| Type | Description |
|---|---|
| DelegateEqualityComparer<T> | A new DelegateEqualityComparer<T> instance. |
Type Parameters
| Name | Description |
|---|---|
| TMember | The type of the member to compare. |
Equals(T?, T?)
Determines whether the specified objects are equal.
Declaration
public bool Equals(T? x, T? y)
Parameters
| Type | Name | Description |
|---|---|---|
| T | x | The first object of type |
| T | y | The second object of type |
Returns
| Type | Description |
|---|---|
| bool | true if the specified objects are equal; otherwise, false. |
GetHashCode(T)
Returns a hash code for the specified object.
Declaration
public int GetHashCode(T obj)
Parameters
| Type | Name | Description |
|---|---|---|
| T | obj | The object for which a hash code is to be returned. |
Returns
| Type | Description |
|---|---|
| int | A hash code for the specified object. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The type of |