A small library which provides a fluent interface to build & create instances of IEqualityComparer<T>, which test value equality between two object instances.
This example builds comparer which is an implementation of IEqualityComparer<ASampleClass>. It will consider two objects equal if:
- Their
PropertyTwoproperty values are equal - And their
PropertyOneproperty values are equal (using a case-insensitive match) PropertyThreewon't be considered for determining equality
// Here's a sample class to compare
public class ASampleClass
{
public string PropertyOne { get; set; }
public int PropertyTwo { get; set; }
public DateTime PropertyThree { get; set; }
}
var comparer = new EqualityBuilder<ASampleClass>()
.ForProperty(x => x.PropertyOne, c => c.UsingComparer(StringComparer.InvariantCultureIgnoreCase))
.ForProperty(x => x.PropertyTwo)
.Build();Full documentation is available on the wiki for this repository. This includes an exploration of how to add rules (including functionality not demonstrated in the example above). It also includes a short piece on integrating with dependency injection frameworks.