public static BaseConstraintGenerator Create(BaseFieldGenerator field, ValidationRule rule) { if (rule is LengthConstraint) return new LengthConstraintGenerator(field, (LengthConstraint)rule); if (rule is RangeConstraint) return new RangeConstraintGenerator(field, (RangeConstraint)rule); if (rule is MatchConstraint) return new MatchConstraintGenerator(field, (MatchConstraint)rule); if (rule is PredefinedValue) return new ListConstraintGenerator(field, (PredefinedValue)rule); if (rule is CodedConstraint) return new CodeConstraintGenerator(field, (CodedConstraint) rule); throw new ApplicationException("Invalid constraint type " + rule.GetType()); }
public ArrayFieldGenerator(FieldInfo fld, BaseFieldGenerator gen) : base(new Primitive() { Access = fld.Access, DeclaringType = fld.DeclaringType, DefaultValue = null, FieldDirection = fld.FieldDirection, FieldId = fld.FieldId, FieldUse = fld.FieldUse, IsArray = false, Name = fld.Name, XmlOptions = fld.XmlOptions, PropertyName = gen.PropertyName, Type = FieldType.Array, Validation = null, }) { _generator = gen; }
public MatchConstraintGenerator(BaseFieldGenerator field, MatchConstraint rule) { _field = field; _rule = rule; }
public static IEnumerable<BaseConstraintGenerator> Create(BaseFieldGenerator field, IEnumerable<ValidationRule> rules) { return rules.SafeEnum().Select(x => Create(field, x)); }
public NotNullConstraintGenerator(BaseFieldGenerator field) { _field = field; }
public IsValidConstraintGenerator(BaseFieldGenerator field) { _field = field; }
public CodeConstraintGenerator(BaseFieldGenerator field, CodedConstraint rule) { _field = field; _rule = rule; }
public ListConstraintGenerator(BaseFieldGenerator field, PredefinedValue rule) { _field = field; _rule = rule; }
public RangeConstraintGenerator(BaseFieldGenerator field, RangeConstraint rule) { _field = field; _rule = rule; }
public LengthConstraintGenerator(BaseFieldGenerator field, LengthConstraint rule) { _field = field; _rule = rule; }