internal InputReferenceExpression CreateReference()
 {
     if (inputRef == null)
     {
         inputRef = new InputReferenceExpression(this);
     }
     return(inputRef);
 }
 internal override Expression VisitInputReferenceExpression(InputReferenceExpression ire)
 {
     if (parent == null || parent.NodeType != ExpressionType.MemberAccess)
     {
         string arg = (parent != null) ? parent.ToString() : ire.ToString();
         throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "The expression {0} is not supported.", arg));
     }
     return(ire);
 }
Ejemplo n.º 3
0
        internal void OverrideInputReference(ResourceSetExpression newInput)
        {
            InputReferenceExpression inputRef = newInput.inputRef;

            if (inputRef != null)
            {
                base.inputRef = inputRef;
                inputRef.OverrideTarget(this);
            }
        }
Ejemplo n.º 4
0
 internal virtual Expression VisitInputReferenceExpression(InputReferenceExpression ire)
 {
     return(((ResourceExpression)Visit(ire.Target)).CreateReference());
 }
Ejemplo n.º 5
0
        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);
        }