Example #1
0
        internal virtual Expression VisitResourceSetExpression(ResourceSetExpression rse)
        {
            Expression expression = Visit(rse.Source);

            if (expression != rse.Source)
            {
                rse = new ResourceSetExpression(rse.Type, expression, rse.MemberExpression, rse.ResourceType, rse.ExpandPaths, rse.CountOption, rse.CustomQueryOptions, rse.Projection);
            }
            return(rse);
        }
Example #2
0
        internal void OverrideInputReference(ResourceSetExpression newInput)
        {
            InputReferenceExpression inputRef = newInput.inputRef;

            if (inputRef != null)
            {
                base.inputRef = inputRef;
                inputRef.OverrideTarget(this);
            }
        }
Example #3
0
        internal void VisitQueryOptions(ResourceExpression re)
        {
            if (!re.HasQueryOptions)
            {
                return;
            }
            ResourceSetExpression resourceSetExpression = re as ResourceSetExpression;

            if (resourceSetExpression != null)
            {
                IEnumerator enumerator = resourceSetExpression.SequenceQueryOptions.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    Expression expression = (Expression)enumerator.Current;
                    switch (expression.NodeType)
                    {
                    case (ExpressionType)10009:
                        VisitQueryOptionExpression((RequestOptionsQueryOptionExpression)expression);
                        break;

                    case (ExpressionType)10010:
                        VisitQueryOptionExpression((OperationContextQueryOptionExpression)expression);
                        break;

                    case (ExpressionType)10011:
                        VisitQueryOptionExpression((EntityResolverQueryOptionExpression)expression);
                        break;

                    case (ExpressionType)10003:
                        VisitQueryOptionExpression((TakeQueryOptionExpression)expression);
                        break;

                    case (ExpressionType)10006:
                        VisitQueryOptionExpression((FilterQueryOptionExpression)expression);
                        break;
                    }
                }
            }
            if (re.Projection != null && re.Projection.Paths.Count > 0)
            {
                Projection    = re.Projection;
                SelectColumns = re.Projection.Paths;
            }
            if (re.CustomQueryOptions.Count > 0)
            {
                VisitCustomQueryOptions(re.CustomQueryOptions);
            }
        }
Example #4
0
 internal override Expression VisitResourceSetExpression(ResourceSetExpression rse)
 {
     VisitQueryOptions(rse);
     return(rse);
 }
        #pragma warning restore 612, 618

        internal void OverrideTarget(ResourceSetExpression newTarget)
        {
            target = newTarget;
        }
        internal override Expression VisitMemberAccess(MemberExpression m)
        {
            if (inputSet == null || !inputSet.HasTransparentScope)
            {
                return(base.VisitMemberAccess(m));
            }
            ParameterExpression  parameterExpression = null;
            Stack <PropertyInfo> stack            = new Stack <PropertyInfo>();
            MemberExpression     memberExpression = m;

            while (memberExpression != null && memberExpression.Member.MemberType == MemberTypes.Property && memberExpression.Expression != null)
            {
                stack.Push((PropertyInfo)memberExpression.Member);
                if (memberExpression.Expression.NodeType == ExpressionType.Parameter)
                {
                    parameterExpression = (ParameterExpression)memberExpression.Expression;
                }
                memberExpression = (memberExpression.Expression as MemberExpression);
            }
            if (parameterExpression != inputParameter || stack.Count == 0)
            {
                return(m);
            }
            ResourceExpression    resource = input;
            ResourceSetExpression resourceSetExpression = inputSet;
            bool flag = false;

            while (stack.Count > 0 && resourceSetExpression != null && resourceSetExpression.HasTransparentScope)
            {
                PropertyInfo propertyInfo = stack.Peek();
                if (propertyInfo.Name.Equals(resourceSetExpression.TransparentScope.Accessor, StringComparison.Ordinal))
                {
                    resource = resourceSetExpression;
                    stack.Pop();
                    flag = true;
                    continue;
                }
                if (!resourceSetExpression.TransparentScope.SourceAccessors.TryGetValue(propertyInfo.Name, out Expression value))
                {
                    break;
                }
                flag = true;
                stack.Pop();
                InputReferenceExpression inputReferenceExpression = value as InputReferenceExpression;
                if (inputReferenceExpression == null)
                {
                    resourceSetExpression = (value as ResourceSetExpression);
                    if (resourceSetExpression == null || !resourceSetExpression.HasTransparentScope)
                    {
                        resource = (ResourceExpression)value;
                    }
                }
                else
                {
                    resourceSetExpression = (inputReferenceExpression.Target as ResourceSetExpression);
                    resource = resourceSetExpression;
                }
            }
            if (!flag)
            {
                return(m);
            }
            Expression expression = CreateReference(resource);

            while (stack.Count > 0)
            {
                expression = Expression.Property(expression, stack.Pop());
            }
            return(expression);
        }
 private InputBinder(ResourceExpression resource, ParameterExpression setReferenceParam)
 {
     input          = resource;
     inputSet       = (resource as ResourceSetExpression);
     inputParameter = setReferenceParam;
 }