예제 #1
0
        /// <summary>
        /// Validate the model and look for errors that would prevent the model from being solved.
        /// <remarks>Populates errors into the <see cref="ModelValidationContext"/> class.</remarks>
        /// </summary>
        /// <returns>True if the model is valid, false if it is not valid.</returns>
        public bool Validate(ModelValidationContext validateContext)
        {
            var returnCodes      = new List <bool>();
            var constraintsValid = ValidateConstraints(validateContext);

            returnCodes.Add(constraintsValid);
            var variablesValid = ValidateVariables(validateContext);

            returnCodes.Add(variablesValid);
            var sharedDomainsValid = ValidateSharedDomains(validateContext);

            returnCodes.Add(sharedDomainsValid);

            return(returnCodes.All(status => status));
        }
예제 #2
0
 private bool ValidateVariables(ModelValidationContext validateContext)
 {
     return(_model.Variables.All(aVariable => aVariable.Validate(_model, validateContext)));
 }
예제 #3
0
 private bool ValidateConstraints(ModelValidationContext validateContext)
 {
     return(_model.Constraints.All(aConstraint => aConstraint.Validate(_model, validateContext)));
 }
예제 #4
0
 private bool ValidateSharedDomains(ModelValidationContext validateContext)
 {
     return(_model.SharedDomains.All(aDomain => aDomain.Validate(_model, validateContext)));
 }