Beispiel #1
0
        public override Boolean IsValid()
        {
            if (!base.IsValid())
            {
                return(false);
            }

            if (!ScanConstraint.IsValuedConstraint(this.Constraint))
            {
                return(true);
            }

            return(this.ConstraintValue != null);
        }
Beispiel #2
0
        /// <summary>
        /// Determines if this constraint conflicts with another constraint.
        /// </summary>
        /// <param name="other">The other scan constraint.</param>
        /// <returns>True if the constraints conflict, otherwise false.</returns>
        public Boolean ConflictsWith(ScanConstraint other)
        {
            if (this.Constraint == other.Constraint)
            {
                return(true);
            }

            if (ScanConstraint.IsRelativeConstraint(this.Constraint) && ScanConstraint.IsRelativeConstraint(other.Constraint))
            {
                return(true);
            }

            if (ScanConstraint.IsValuedConstraint(this.Constraint) && ScanConstraint.IsValuedConstraint(other.Constraint))
            {
                if (!ScanConstraint.IsRelativeConstraint(this.Constraint) && !ScanConstraint.IsRelativeConstraint(other.Constraint))
                {
                    if ((this.Constraint == ConstraintType.LessThan || this.Constraint == ConstraintType.LessThanOrEqual || this.Constraint == ConstraintType.NotEqual) &&
                        (other.Constraint == ConstraintType.GreaterThan || other.Constraint == ConstraintType.GreaterThanOrEqual || other.Constraint == ConstraintType.NotEqual))
                    {
                        if ((dynamic)this.ConstraintValue <= (dynamic)other.ConstraintValue)
                        {
                            return(true);
                        }

                        return(false);
                    }

                    if ((this.Constraint == ConstraintType.GreaterThan || this.Constraint == ConstraintType.GreaterThanOrEqual || this.Constraint == ConstraintType.NotEqual) &&
                        (other.Constraint == ConstraintType.LessThan || other.Constraint == ConstraintType.LessThanOrEqual || other.Constraint == ConstraintType.NotEqual))
                    {
                        if ((dynamic)this.ConstraintValue >= (dynamic)other.ConstraintValue)
                        {
                            return(true);
                        }

                        return(false);
                    }

                    return(true);
                }
            }

            return(false);
        }