public ValidationResult Validate(ProcessedStatement currentStatement, IList <ProcessedStatement> contractBlock) { var validationResult = DoValidate(currentStatement, contractBlock); validationResult.SetProcessedStatement(currentStatement); return(validationResult); }
internal void SetProcessedStatement(ProcessedStatement processedStatement) { Contract.Requires(processedStatement != null); Contract.Requires(processedStatement.CSharpStatement == Statement, "Processed statement should have the same CSharpStatement that you passed to the constructor!"); _processedStatement = processedStatement; }
protected override ValidationResult DoValidate(ProcessedStatement currentStatement, IList <ProcessedStatement> contractBlock) { if (currentStatement.ContractStatement == null) { return(ValidationResult.CreateNoError(currentStatement.CSharpStatement)); } return(_validationFunc(currentStatement.ContractStatement)); }
public ValidatedStatement(ProcessedStatement processedStatement, IList <ValidationResult> validationResults) { Contract.Requires(processedStatement != null); Contract.Requires(validationResults != null); _processedStatement = processedStatement; _validationResults = validationResults.Count == 0 ? new[] { ValidationResult.CreateNoError(processedStatement.CSharpStatement) } : validationResults; }
private static IEnumerable <ValidationResult> ValidateStatement(IList <ValidationRule> validationRules, IList <ProcessedStatement> contractBlock, ProcessedStatement currentStatement) { Contract.Requires(contractBlock != null); Contract.Requires(currentStatement != null); Contract.Ensures(Contract.Result <IEnumerable <ValidationResult> >() != null); return(validationRules .Select(rule => rule.Validate(currentStatement, contractBlock)) .Where(vr => vr.ErrorType != ErrorType.NoError) .ToList()); }
protected abstract ValidationResult DoValidate(ProcessedStatement currentStatement, IList <ProcessedStatement> contractBlock);