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); }
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; } }
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)); }