private static IEnumerable<Action<XmlWriter, ValidationOptions>> GetIntegerConstraints(ValidationOptions options, ApplicableOptions optsToUse) { var integerDigitsDefined = HasValue(options.IntegerDigits); var fractionalDigitsDefined = HasValue(options.FractionalDigits); var minValueDefined = HasValue(options.MinimumValue); var maxValueDefined = HasValue(options.MaximumValue); if (optsToUse.IsSet(ApplicableOptions.Value) && (minValueDefined || maxValueDefined)) { yield return (w, p) => { w.WriteStartElement("range", "urn:nhibernate-validator-1.0"); if (minValueDefined) w.WriteAttributeString("min", p.MinimumValue.Value.ToString(CultureInfo.InvariantCulture)); if (maxValueDefined) w.WriteAttributeString("max", p.MaximumValue.Value.ToString(CultureInfo.InvariantCulture)); w.WriteEndElement(); }; } if (optsToUse.IsSet(ApplicableOptions.Digits) && (integerDigitsDefined || fractionalDigitsDefined)) { yield return (w, p) => { w.WriteStartElement("digits", "urn:nhibernate-validator-1.0"); if (integerDigitsDefined) w.WriteAttributeString("integerDigits", p.IntegerDigits.Value.ToString(CultureInfo.InvariantCulture)); if (fractionalDigitsDefined) w.WriteAttributeString("fractionalDigits", p.FractionalDigits.Value.ToString(CultureInfo.InvariantCulture)); w.WriteEndElement(); }; } }
private SlyceTreeGridCellItem CreateNewNullableCell(ComponentPropertyImpl property, object value, ApplicableOptions options) { ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type); SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options); cell.IsNullable = true; return(cell); }
private SlyceTreeGridCellItem CreateNewNullableCell(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, object value, ApplicableOptions options) { ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type); SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options); cell.IsNullable = true; return(cell); }
private static IEnumerable<Action<XmlWriter, ValidationOptions>> GetDateConstraints(ValidationOptions options, ApplicableOptions optsToUse) { if (!optsToUse.IsSet(ApplicableOptions.Date)) yield break; if (options.PastDate.HasValue && options.PastDate == true) yield return (w, p) => w.WriteElementString("past", "urn:nhibernate-validator-1.0", ""); if (options.FutureDate.HasValue && options.FutureDate == true) yield return (w, p) => w.WriteElementString("future", "urn:nhibernate-validator-1.0", ""); }
public void SetAvailableOptions(ApplicableOptions options) { OptionsVisibility.Clear(); OptionsVisibility.Add("nhv_nullable", options.IsSet(ApplicableOptions.Nullable)); OptionsVisibility.Add("nhv_validate", options.IsSet(ApplicableOptions.Validate)); OptionsVisibility.Add("nhv_min_value", options.IsSet(ApplicableOptions.Value)); OptionsVisibility.Add("nhv_max_value", options.IsSet(ApplicableOptions.Value)); OptionsVisibility.Add("nhv_int_digits", options.IsSet(ApplicableOptions.Digits)); OptionsVisibility.Add("nhv_frac_digits", options.IsSet(ApplicableOptions.Digits)); OptionsVisibility.Add("nhv_not_empty", options.IsSet(ApplicableOptions.NotEmpty)); OptionsVisibility.Add("nhv_min_length", options.IsSet(ApplicableOptions.Length)); OptionsVisibility.Add("nhv_max_length", options.IsSet(ApplicableOptions.Length)); OptionsVisibility.Add("nhv_reg_exp", options.IsSet(ApplicableOptions.RegexPattern)); OptionsVisibility.Add("nhv_past_date", options.IsSet(ApplicableOptions.Date)); OptionsVisibility.Add("nhv_future_date", options.IsSet(ApplicableOptions.Date)); SetNodeVisibility(); }
private SlyceTreeGridCellItem CreateNewNullableCell(ComponentPropertyImpl property, object value, ApplicableOptions options) { ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type); SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options); cell.IsNullable = true; return cell; }
private static IEnumerable<Action<XmlWriter, ValidationOptions>> GetStringConstraints(ValidationOptions options, ApplicableOptions optsToUse) { var maxLengthDefined = options.MaximumLength.HasValue && options.MaximumLength > 0 && options.MaximumLength < int.MaxValue; var minLengthDefined = options.MinimumLength.HasValue && options.MinimumLength > 0 && options.MinimumLength < int.MaxValue; var notEmptyDefined = options.NotEmpty.HasValue && options.NotEmpty.Value; var regexDefined = !string.IsNullOrEmpty(options.RegexPattern); if (optsToUse.IsSet(ApplicableOptions.NotEmpty) && notEmptyDefined) yield return (w, p) => w.WriteElementString("not-empty", "urn:nhibernate-validator-1.0", ""); if (optsToUse.IsSet(ApplicableOptions.RegexPattern) && regexDefined) { yield return (w, p) => { w.WriteStartElement("pattern", "urn:nhibernate-validator-1.0"); w.WriteAttributeString("regex", options.RegexPattern); w.WriteEndElement(); }; } if (optsToUse.IsSet(ApplicableOptions.Value) && (maxLengthDefined || minLengthDefined)) { yield return (w, p) => { w.WriteStartElement("length", "urn:nhibernate-validator-1.0"); if (maxLengthDefined) w.WriteAttributeString("max", p.MaximumLength.ToString()); if (minLengthDefined) w.WriteAttributeString("min", p.MinimumLength.ToString()); w.WriteEndElement(); }; } }
private static IEnumerable<Action<XmlWriter, ValidationOptions>> GetObjectConstraints(ValidationOptions options, ApplicableOptions optsToUse) { if (optsToUse.IsSet(ApplicableOptions.Nullable) && options.Nullable.HasValue && options.Nullable == false) yield return (w, p) => w.WriteElementString("not-null", "urn:nhibernate-validator-1.0", ""); if (optsToUse.IsSet(ApplicableOptions.Validate) && options.Validate) yield return (w, p) => w.WriteElementString("valid", "urn:nhibernate-validator-1.0", ""); }
public static bool IsSet(this ApplicableOptions options, ApplicableOptions flags) { return((options & flags) == flags); }
private static IEnumerable <Action <XmlWriter, ValidationOptions> > GetStringConstraints(ValidationOptions options, ApplicableOptions optsToUse) { var maxLengthDefined = options.MaximumLength.HasValue && options.MaximumLength > 0 && options.MaximumLength < int.MaxValue; var minLengthDefined = options.MinimumLength.HasValue && options.MinimumLength > 0 && options.MinimumLength < int.MaxValue; var notEmptyDefined = options.NotEmpty.HasValue && options.NotEmpty.Value; var regexDefined = !string.IsNullOrEmpty(options.RegexPattern); if (optsToUse.IsSet(ApplicableOptions.NotEmpty) && notEmptyDefined) { yield return((w, p) => w.WriteElementString("not-empty", "urn:nhibernate-validator-1.0", "")); } if (optsToUse.IsSet(ApplicableOptions.RegexPattern) && regexDefined) { yield return((w, p) => { w.WriteStartElement("pattern", "urn:nhibernate-validator-1.0"); w.WriteAttributeString("regex", options.RegexPattern); w.WriteEndElement(); }); } if (optsToUse.IsSet(ApplicableOptions.Value) && (maxLengthDefined || minLengthDefined)) { yield return((w, p) => { w.WriteStartElement("length", "urn:nhibernate-validator-1.0"); if (maxLengthDefined) { w.WriteAttributeString("max", p.MaximumLength.ToString()); } if (minLengthDefined) { w.WriteAttributeString("min", p.MinimumLength.ToString()); } w.WriteEndElement(); }); } }
private static IEnumerable <Action <XmlWriter, ValidationOptions> > GetDateConstraints(ValidationOptions options, ApplicableOptions optsToUse) { if (!optsToUse.IsSet(ApplicableOptions.Date)) { yield break; } if (options.PastDate.HasValue && options.PastDate == true) { yield return((w, p) => w.WriteElementString("past", "urn:nhibernate-validator-1.0", "")); } if (options.FutureDate.HasValue && options.FutureDate == true) { yield return((w, p) => w.WriteElementString("future", "urn:nhibernate-validator-1.0", "")); } }
private static IEnumerable <Action <XmlWriter, ValidationOptions> > GetObjectConstraints(ValidationOptions options, ApplicableOptions optsToUse) { if (optsToUse.IsSet(ApplicableOptions.Nullable) && options.Nullable.HasValue && options.Nullable == false) { yield return((w, p) => w.WriteElementString("not-null", "urn:nhibernate-validator-1.0", "")); } if (optsToUse.IsSet(ApplicableOptions.Validate) && options.Validate) { yield return((w, p) => w.WriteElementString("valid", "urn:nhibernate-validator-1.0", "")); } }
private static IEnumerable <Action <XmlWriter, ValidationOptions> > GetIntegerConstraints(ValidationOptions options, ApplicableOptions optsToUse) { var integerDigitsDefined = HasValue(options.IntegerDigits); var fractionalDigitsDefined = HasValue(options.FractionalDigits); var minValueDefined = HasValue(options.MinimumValue); var maxValueDefined = HasValue(options.MaximumValue); if (optsToUse.IsSet(ApplicableOptions.Value) && (minValueDefined || maxValueDefined)) { yield return((w, p) => { w.WriteStartElement("range", "urn:nhibernate-validator-1.0"); if (minValueDefined) { w.WriteAttributeString("min", p.MinimumValue.Value.ToString(CultureInfo.InvariantCulture)); } if (maxValueDefined) { w.WriteAttributeString("max", p.MaximumValue.Value.ToString(CultureInfo.InvariantCulture)); } w.WriteEndElement(); }); } if (optsToUse.IsSet(ApplicableOptions.Digits) && (integerDigitsDefined || fractionalDigitsDefined)) { yield return((w, p) => { w.WriteStartElement("digits", "urn:nhibernate-validator-1.0"); if (integerDigitsDefined) { w.WriteAttributeString("integerDigits", p.IntegerDigits.Value.ToString(CultureInfo.InvariantCulture)); } if (fractionalDigitsDefined) { w.WriteAttributeString("fractionalDigits", p.FractionalDigits.Value.ToString(CultureInfo.InvariantCulture)); } w.WriteEndElement(); }); } }
public static bool IsSet(this ApplicableOptions options, ApplicableOptions flags) { return (options & flags) == flags; }
private SlyceTreeGridCellItem CreateNewNullableCell(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, object value, ApplicableOptions options) { ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type); SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options); cell.IsNullable = true; return cell; }