registerEqualityComparer<T> static method
Registers an EqualityComparer object as the default comparer for type T
,
returning a bool
stating if a comparer already exists.
If overwrite
is true
, the comparer will replace any existing comparer
registered under T
with the given one. If overwrite
is false
and a
comparer for T
is already registered, the new comparer is ignored. (overwrite
defaults to false
.)
In either case, this method returns true
if a comparer is already registered
under type T
, and false
otherwise.
Implementation
static bool registerEqualityComparer<T>(EqualityComparer<T> comparer,
{bool overwrite = false}) {
var typeExists = _registeredEqualityComparers.containsKey(T);
if (!typeExists || overwrite) _registeredEqualityComparers[T] = comparer;
return typeExists;
}