Exemplo n.º 1
0
 public void SetUp()
 {
     substitution = new Substitution();
     marker       = new MappingIdentifierMarker();
 }
Exemplo n.º 2
0
        protected Expression GetReplacedExpression(Expression expression, string mapKey)
        {
            bool removeId = false;
            bool isCurrent = false;
            if (mapKey.StartsWith("!"))
            {
                removeId = true;
                mapKey = mapKey.Substring(1);
            }
            else if (mapKey.StartsWith("="))
            {
                mapKey = mapKey.Substring(1);
                isCurrent = true;
            }

            AssignmentExpression mappedExpression = (AssignmentExpression) GetMapExpression(mapKey);

            Substitution substitution = new Substitution();
            List<Expression> parameters = GetParameters(expression);
            Expression targetId = GetTargetObject(expression);
            substitution.Identifier = targetId;
            if (!removeId)
            {
                if (expression is InvocationExpression)
                {
                    InvocationExpression invocationExpression = (InvocationExpression) expression;
                    if (invocationExpression.TargetObject is FieldReferenceExpression)
                    {
                        FieldReferenceExpression invocationTarget = (FieldReferenceExpression) invocationExpression.TargetObject;
                        if (mappedExpression.Right is InvocationExpression)
                        {
                            IdentifierExpression identifierExpression = GetIdentifierExpression((InvocationExpression) mappedExpression.Right);
                            if (identifierExpression != null)
                            {
                                FieldReferenceExpression referenceExpression = new FieldReferenceExpression(invocationTarget.TargetObject, identifierExpression.Identifier);
                                Expression identifierParent = (Expression) identifierExpression.Parent;
                                if (identifierParent is InvocationExpression)
                                    ((InvocationExpression) identifierParent).TargetObject = referenceExpression;
                            }
                        }
                        else if (mappedExpression.Right is IdentifierExpression)
                        {
                            FieldReferenceExpression referenceExpression = new FieldReferenceExpression(invocationTarget.TargetObject, ((IdentifierExpression) mappedExpression.Right).Identifier);
                            mappedExpression.Right = referenceExpression;
                        }
                    }
                }
            }

            substitution.Substitute(mappedExpression, parameters);
            mappedExpression.Right.Parent = expression.Parent;
            if (isCurrent)
                mappedExpression.Right.StartLocation = new Location(-1, -1);
            return mappedExpression.Right;
        }
Exemplo n.º 3
0
        protected Expression GetReplacedExpression(Expression expression, string mapKey)
        {
            bool removeId  = false;
            bool isCurrent = false;

            if (mapKey.StartsWith("!"))
            {
                removeId = true;
                mapKey   = mapKey.Substring(1);
            }
            else if (mapKey.StartsWith("="))
            {
                mapKey    = mapKey.Substring(1);
                isCurrent = true;
            }

            AssignmentExpression mappedExpression = (AssignmentExpression)GetMapExpression(mapKey);

            Substitution      substitution = new Substitution();
            List <Expression> parameters   = GetParameters(expression);
            Expression        targetId     = GetTargetObject(expression);

            substitution.Identifier = targetId;
            if (!removeId)
            {
                if (expression is InvocationExpression)
                {
                    InvocationExpression invocationExpression = (InvocationExpression)expression;
                    if (invocationExpression.TargetObject is FieldReferenceExpression)
                    {
                        FieldReferenceExpression invocationTarget = (FieldReferenceExpression)invocationExpression.TargetObject;
                        if (mappedExpression.Right is InvocationExpression)
                        {
                            IdentifierExpression identifierExpression = GetIdentifierExpression((InvocationExpression)mappedExpression.Right);
                            if (identifierExpression != null)
                            {
                                FieldReferenceExpression referenceExpression = new FieldReferenceExpression(invocationTarget.TargetObject, identifierExpression.Identifier);
                                Expression identifierParent = (Expression)identifierExpression.Parent;
                                if (identifierParent is InvocationExpression)
                                {
                                    ((InvocationExpression)identifierParent).TargetObject = referenceExpression;
                                }
                            }
                        }
                        else if (mappedExpression.Right is IdentifierExpression)
                        {
                            FieldReferenceExpression referenceExpression = new FieldReferenceExpression(invocationTarget.TargetObject, ((IdentifierExpression)mappedExpression.Right).Identifier);
                            mappedExpression.Right = referenceExpression;
                        }
                    }
                }
            }

            substitution.Substitute(mappedExpression, parameters);
            mappedExpression.Right.Parent = expression.Parent;
            if (isCurrent)
            {
                mappedExpression.Right.StartLocation = new Location(-1, -1);
            }
            return(mappedExpression.Right);
        }
Exemplo n.º 4
0
 public void SetUp()
 {
     substitution = new Substitution();
     marker = new MappingIdentifierMarker();
 }