-
Notifications
You must be signed in to change notification settings - Fork 0
EqualityBuilder
The equality builder is the class which is used to specify how an equality comparer should operate. The equality builder is created using the constructor, for example:
var builder = new EqualityBuilder<T>();
Once the builder is created, it is ready for the addition of equality rules.
The constructor for an equality builder accepts an optional service resolver parameter. If provided, this allows integration with a dependency injection framework.
If you integrate in this way, then any equality rule classes used when adding rules to the builder will be resolved using the provided resolver.
To use a custom resolver, create a (typically very small) class which implements the interface IResolvesServices
. This class should wrap the resolver for the dependency injection framework you wish to use. Provide an instance of this class to the constructor of the builder.
A static function is provided for convenience in order to create an equality tester from an existing equality comparer:
// 'myComparer' is an instance of IEqualityComparer<T>
// 'tester' will be an instance of IGetsEqualityResult<T>
var tester = EqualityBuilder.From(myComparer);