Example #1
0
        public override LambdaExpression VisitValPathPresentExp(ScimFilterParser.ValPathPresentExpContext context)
        {
            var propertyNameToken = context.FIELD().GetText();

            var property = PropertyCache
                           .GetOrAdd(
                typeof(TResource),
                type =>
                type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                .ToDictionary(pi => pi.Name, pi => pi, StringComparer.OrdinalIgnoreCase))[propertyNameToken];

            if (property == null)
            {
                throw new Exception("eeeerrrooorrr");                   // TODO: (DG) proper error handling
            }
            if (property.GetGetMethod() == null)
            {
                throw new Exception("error");
            }

            var argument  = Expression.Parameter(typeof(TResource));
            var predicate = Expression.Lambda <Func <TResource, bool> >(
                Expression.Call(
                    MethodCache["pr"]
                    .MakeGenericMethod(typeof(TResource)),
                    new List <Expression>
            {
                argument,
                Expression.Constant(property)
            }),
                argument);

            return(predicate);
        }
Example #2
0
        public override LambdaExpression VisitValPathPresentExp(ScimFilterParser.ValPathPresentExpContext context)
        {
            var argument           = Expression.Parameter(typeof(TResource));
            var attrPathExpression = Visit(context.attrPath());

            return(Expression.Lambda <Func <TResource, bool> >(
                       Expression.Call(
                           MethodCache["pr"].MakeGenericMethod(attrPathExpression.ReturnType), Expression.Invoke(attrPathExpression, argument)),
                       argument));
        }