示例#1
0
    public void SetValue(int value)
    {
        this.Value = value;
        this.AvailableValues.Remove(value);

        PermittedValues.DeleteRowPermittedValue(this.Row, this.Value);
        PermittedValues.DeleteColPermittedValue(this.Column, this.Value);
        PermittedValues.DeleteSectionPermittedValue(this.Section, this.Value);
    }
示例#2
0
    public void UnsetValue()
    {
        if (this.Value != 0)
        {
            PermittedValues.AddRowPermittedValue(this.Row, this.Value);
            PermittedValues.AddColPermittedValue(this.Column, this.Value);
            PermittedValues.AddSectionPermittedValue(this.Section, this.Value);

            this.Value = 0;
        }
    }
示例#3
0
        protected override ValidationResult OnValidate(object value, string fieldName)
        {
            var intValue = Convert.ToInt32(value);
            var isValid  = PermittedValues.Contains(intValue);

            if (isValid)
            {
                return(ValidationResult.Pass(fieldName));
            }

            var validationMessage = string.Format("The value {0} is not valid for the field {1} as it does not conform to one of the following restriction values {2}", intValue, fieldName, string.Join(",", PermittedValues));

            return(ValidationResult.Fail(fieldName, validationMessage));
        }
        protected override ValidationResult OnValidate(object value, string fieldName)
        {
            var stringValue = value.ToString();

            if (stringValue.Equals(string.Empty) && AllowEmptyStrings)
            {
                return(ValidationResult.Pass(fieldName));
            }

            var isValid = !IsCaseSensitive?PermittedValues.Any(r => r.Equals(stringValue, StringComparison.OrdinalIgnoreCase)) : PermittedValues.Any(r => r.Equals(stringValue));

            if (isValid)
            {
                return(ValidationResult.Pass(fieldName));
            }

            var validationMessage = string.Format("The value '{0}' is not valid for the field '{1}' as it does not conform to one of the following restriction values {2}", stringValue, fieldName, string.Join(",", PermittedValues));

            return(ValidationResult.Fail(fieldName, validationMessage));
        }