private JSchema MapBasicArray(string _type, IRestrictable restrictable)
        {
            var schema = new JSchema
            {
                Type = JSchemaType.Array
            };

            schema.Items.Add(JsonMapper.MapBasicType(_type, restrictable, this.CarConfig));
            return(schema);
        }
        private JSchema?MapDefinition(string _mod, string _type, IRestrictable restrictable)
        {
            var isBasicType = JsonMapper.IsBasicType(_type);
            var min         = restrictable.Restrictions.FirstOrDefault(r => r.Key == "min");
            var max         = restrictable.Restrictions.FirstOrDefault(r => r.Key == "max");
            var pattern     = restrictable.Restrictions.FirstOrDefault(r => r.Key == "pattern");
            var decimals    = restrictable.Restrictions.FirstOrDefault(r => r.Key == "decimals");

            JSchema?result;

            if (_mod == "List" && isBasicType)
            {
                result = MapBasicArray(_type, restrictable);
                result.MinimumItems = int.Parse(min?.Value ?? this.CarConfig.DefaultRestrictions.ListRestrictions.Min.ToString());
                result.MaximumItems = int.Parse(min?.Value ?? this.CarConfig.DefaultRestrictions.ListRestrictions.Max.ToString());
            }
            else if (_mod == "List" && !isBasicType)
            {
                var temp = MapAstNode(_type);
                result = new JSchema
                {
                    Type         = JSchemaType.Array,
                    MinimumItems = int.Parse(min?.Value ?? this.CarConfig.DefaultRestrictions.ListRestrictions.Min.ToString()),
                    MaximumItems = int.Parse(min?.Value ?? this.CarConfig.DefaultRestrictions.ListRestrictions.Max.ToString())
                };
                result.Items.Add(temp);
            }
            else if (isBasicType)
            {
                result = JsonMapper.MapBasicType(_type, restrictable, this.CarConfig);
            }
            else
            {
                result = MapAstNode(_type);
            }
            return(result);
        }
Esempio n. 3
0
 public MoranbernateRestrictions(IRestrictable <T> restrictable)
 {
     _restrictable = restrictable;
 }
Esempio n. 4
0
 public static IRestrictable <T> EndWith <T>(this IRestrictable <T> restrictable, Expression <Func <T, object> > member, string value)
 {
     return(LikeActions(restrictable, member, "%" + value));
 }
Esempio n. 5
0
 public static IRestrictable <T> LessThan <T, TValue>(this IRestrictable <T> restrictable, Expression <Func <T, TValue> > member, TValue value)
 {
     return(restrictable.AddRestriction(new OperatorRestriction <TValue>(ExpressionProcessor <T> .GetPropertyFromCache(member), value, "<")));
 }
Esempio n. 6
0
 public static IRestrictable <T> IsNotNull <T, TValue>(this IRestrictable <T> restrictable, Expression <Func <T, TValue> > member)
 {
     return(restrictable.AddRestriction(new IsNullRestriction(ExpressionProcessor <T> .GetPropertyFromCache(member), not: true)));
 }
Esempio n. 7
0
 public static IRestrictable <T> Or <T>(this IRestrictable <T> restrictable, params Func <IRestrictable <T>, IRestrictable <T> >[] restrictions)
 {
     return(restrictable.AddRestriction(new OrRestriction <T>(restrictions)));
 }
Esempio n. 8
0
 public static IRestrictable <T> NotIn <T, TValue>(this IRestrictable <T> restrictable, Expression <Func <T, TValue> > member, ICollection <TValue> value)
 {
     return(restrictable.AddRestriction(new InRestriction <TValue>(ExpressionProcessor <T> .GetPropertyFromCache(member), value, not: true)));
 }
Esempio n. 9
0
 private static IRestrictable <T> LikeActions <T>(IRestrictable <T> restrictable, Expression <Func <T, object> > member, string value)
 {
     return(restrictable.AddRestriction(new OperatorRestriction <string>(ExpressionProcessor <T> .GetPropertyFromCache(member), value, "LIKE")));
 }
Esempio n. 10
0
 public static IRestrictable <T> RegexMatch <T>(this IRestrictable <T> restrictable, Expression <Func <T, object> > member, string pattern)
 {
     return(restrictable.AddRestriction(new RegexRestriction <string>(ExpressionProcessor <T> .GetPropertyFromCache(member), pattern)));
 }
Esempio n. 11
0
 public static IRestrictable <T> NotLike <T>(this IRestrictable <T> restrictable, Expression <Func <T, object> > member, string value)
 {
     return(restrictable.AddRestriction(new OperatorRestriction <string>(ExpressionProcessor <T> .GetPropertyFromCache(member), "%" + value + "%", "NOT LIKE")));
 }
Esempio n. 12
0
 public static IRestrictable <T> StartWith <T>(this IRestrictable <T> restrictable, Expression <Func <T, string> > member, string value)
 {
     return(LikeActions(restrictable, member, value + "%"));
 }
Esempio n. 13
0
 public static IRestrictable <T> Contains <T>(this IRestrictable <T> restrictable, Expression <Func <T, string> > member, string value)
 {
     return(LikeActions(restrictable, member, "%" + value + "%"));
 }