public ErrorValidationEvent Validate(ValidationRequest request, FlowErrorTrace parent) { ObjectBinder binder = request.Binder; // todo: check IComparable casting is possible IComparable comparableComaredObject = null; IComparable comparableToCheck = null; // bind 1st object try { comparableToCheck = binder.Bind(Property); }catch (Exception e) { return(new UnableToBindEvent(parent, e, this, Property, 1)); } if (ComparedObject.GetType().Equals(typeof(PropertySelection))) { // bind 2nd object PropertySelection selected = (PropertySelection)ComparedObject; try { comparableComaredObject = binder.Bind(selected); } catch (Exception e) { return(new UnableToBindEvent(parent, e, this, selected, 2)); } } else { // set 2nd object try { comparableComaredObject = (IComparable)ComparedObject; } catch (Exception e) { return(new RuleRuntimeErrorEvent(parent, e, this, comparableToCheck, comparableComaredObject)); } } // evaluate try { if (Operator.Evaluate(comparableToCheck, comparableComaredObject) == false) { return(new UnsuccessfulRuleCompletionEvent(parent, this, comparableToCheck, comparableComaredObject)); } else { return(null); } } catch (Exception e) { return(new RuleRuntimeErrorEvent(parent, e, this, comparableToCheck, comparableComaredObject)); } }
// number of errors! public ValidationResult(FlowErrorTrace errorTrace) { this.errorTrace = errorTrace; events = new List <ErrorValidationEvent>(); if (errorTrace != null) { AddErrors(errorTrace, events); } }
private static void AddErrors(FlowErrorTrace errorTrace, List <ErrorValidationEvent> events) { foreach (ErrorValidationEvent e in errorTrace.ErrorEvents) { events.Add(e); } foreach (FlowErrorTrace e in errorTrace.FlowErrors) { AddErrors(e, events); } }
public void AddFlowErrorTrace(FlowErrorTrace flowError) { if (flowError == null) { emptyTrace = true; } else { flowError.Parent = this; flowErrors.Add(flowError); } }
public FlowErrorTrace Validate(ValidationRequest request) { FlowErrorTrace flowErrorTrace = new FlowErrorTrace(this); foreach (ValidationFlow flow in flows) { FlowErrorTrace lastFlowTrace = flow.Validate(request); flowErrorTrace.AddFlowErrorTrace(lastFlowTrace); } foreach (ValidationRule rule in rules) { ErrorValidationEvent validationEvent = rule.Validate(request, flowErrorTrace); flowErrorTrace.AddErrorValidationEvent(validationEvent); } if (flowErrorTrace.containsMajorValidationErrors()) { return(flowErrorTrace); } else { return(null); } }