private static object GetSingleValue(Type type, RsqlParser.ComparisonContext context) { type = type ?? throw new ArgumentNullException(nameof(type)); context = context ?? throw new ArgumentNullException(nameof(context)); var value = context.arguments().value(); if (value.Length > 1) { throw new TooManyArgumentsException(context); } return(ValueParser.GetValue(type, value.First())); }
public Expression <Func <T, bool> > InComparator <T>(ParameterExpression parameter, RsqlParser.ComparisonContext context) { parameter = parameter ?? throw new ArgumentNullException(nameof(parameter)); context = context ?? throw new ArgumentNullException(nameof(context)); var expressionPath = this._propertyAccessor.ParsePath(parameter, context.selector().GetText()); this.EnsureEquatable(expressionPath.Type, context); var values = ValueParser.GetValues(expressionPath.Type, context.arguments()); var methodContainsInfo = ContainsHelper.GetOrRegistryContainsMethodInfo(expressionPath.Type); return(Expression.Lambda <Func <T, bool> >( ComparisonBuilder.PathNotNull( expressionPath, Expression.Call( Expression.Constant(methodContainsInfo.Convert(values)), methodContainsInfo.ContainsMethod, expressionPath.Expression)), parameter)); }