public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator parent, IEquivalencyAssertionOptions config) { bool success = false; using (var scope = new AssertionScope()) { // Try without conversion if (AppliesTo(context)) { success = ExecuteAssertion(context); } bool converted = false; if (!success && converter.CanHandle(context, config)) { // Convert into a child context context = context.Clone(); converter.Handle(context, parent, config); converted = true; } if (converted && AppliesTo(context)) { // Try again after conversion success = ExecuteAssertion(context); if (success) { // If the assertion succeeded after conversion, discard the failures from // the previous attempt. If it didn't, let the scope throw with those failures. scope.Discard(); } } } return(success); }