LambdaComparer
In many .Net and SF API a IComparer or IEqualityComparer is taken as a parameter of the constructor of a data structure or a method.
Implementing a IComparer nowadays looks like too ceremonial, too Javaish... lambda comparer makes it simpler.
public class LambdaComparer<T, S> : IComparer<T>, IEqualityComparer<T>, IComparer, IEqualityComparer
{
public LambdaComparer(Func<T, S> func){..}
(...)
{
Example:
List<Person> people = (...);
people.Sort(new LambdaComparer<Person, string>(p=>p.Name));
LambdaComparer now also implements IComparer and IEqualityComparer
ReferenceEqualityComparer
By default the default implementation of Equals and GetHashCode for all .Net uses the object referenceb, but when you override both of the methods you get the default implementation lost.
i.e:
IdentifiableEntity for example overrides it to use Type and Id for convenience when writing business logic.
ReferenceEqualityComparer allows you to change back this behavior in whatever data structure or algorithm that takes an IEqualityComparer.
public class ReferenceEqualityComparer<T> : IEqualityComparer<T>, IEqualityComparer where T : class
{
public static ReferenceEqualityComparer<T> Default {get; }
}
Example:
var memoryGraph = new DirectedGraph<Modifiable>(ReferenceEqualityComparer<Modifiable>.Default);