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); }
public MoranbernateRestrictions(IRestrictable <T> restrictable) { _restrictable = restrictable; }
public static IRestrictable <T> EndWith <T>(this IRestrictable <T> restrictable, Expression <Func <T, object> > member, string value) { return(LikeActions(restrictable, member, "%" + value)); }
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, "<"))); }
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))); }
public static IRestrictable <T> Or <T>(this IRestrictable <T> restrictable, params Func <IRestrictable <T>, IRestrictable <T> >[] restrictions) { return(restrictable.AddRestriction(new OrRestriction <T>(restrictions))); }
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))); }
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"))); }
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))); }
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"))); }
public static IRestrictable <T> StartWith <T>(this IRestrictable <T> restrictable, Expression <Func <T, string> > member, string value) { return(LikeActions(restrictable, member, value + "%")); }
public static IRestrictable <T> Contains <T>(this IRestrictable <T> restrictable, Expression <Func <T, string> > member, string value) { return(LikeActions(restrictable, member, "%" + value + "%")); }