Represents assignment to a member of an object.
Inheritance: MemberBinding
Ejemplo n.º 1
0
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            string propertyName = node.Member.Name;
            string fieldName = DbMetaDataManager.GetFieldName(node.Member.DeclaringType, propertyName);

            if (node.Expression.NodeType == ExpressionType.Call)
            {

                VisitMethodCall((MethodCallExpression)node.Expression,fieldName);
            }
            else if (node.Expression.NodeType == ExpressionType.Convert)
            {
                var ue = node.Expression as UnaryExpression;
                var call = ue.Operand as MethodCallExpression;

                if (call != null)
                    this.VisitMethodCall(call, fieldName);
                else
                    this.MyVisitMember(ue.Operand as MemberExpression,fieldName);
            }
            else
            {
                parameters.Add(fieldName, new Parameter(ParamPrefix + fieldName, null));
                var constant = node.Expression as ConstantExpression;
                if (constant != null)
                    VisitConstant(constant, fieldName);
                else
                {
                    LambdaExpression lambda = Expression.Lambda(node.Expression);
                    var fn = lambda.Compile();
                    VisitConstant(Expression.Constant(fn.DynamicInvoke(null), node.Expression.Type), fieldName);
                }
            }
            return node;
        }
Ejemplo n.º 2
0
 protected MemberAssignment UpdateMemberAssignment(MemberAssignment assignment, MemberInfo member, Expression expression)
 {
     if (expression != assignment.Expression || member != assignment.Member) {
         return Expression.Bind(member, expression);
     }
     return assignment;
 }
Ejemplo n.º 3
0
		protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
		{
			this.output.Append(assignment.Member.Name).Append(" = ");
			this.Visit(assignment.Expression);

			return assignment;
		}
Ejemplo n.º 4
0
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            var property = assignment.Member as PropertyInfo;
            if (property == null)
            {
                throw new NotSupportedException(
                    String.Format("{0} is not a property.", assignment.Member));
            }

            IPropertyUpdate update;
            var expr = PartialEval(assignment.Expression);
            switch (expr.NodeType)
            {
                case ExpressionType.Constant:
                    update = ConstantUpdate.Create(property, (ConstantExpression)expr);
                    break;
                case ExpressionType.Add:
                case ExpressionType.Subtract:
                    update = BinaryUpdate.Create(property, (BinaryExpression)expr);
                    break;
                case ExpressionType.Call:
                    update = MethodCallUpdate.Create(property, (MethodCallExpression)expr);
                    break;
                default:
                    throw new NotSupportedException();
            }

            this.m_updates.Add(update);

            return assignment;
        }
Ejemplo n.º 5
0
 public static MemberAssignment Serialize(E.MemberAssignment binding)
 {
     return(new MemberAssignment()
     {
         Member = MemberRef.Serialize(binding.Member),
         Expression = Node.Serialize(binding.Expression),
     });
 }
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     var saveMember = this.currentMember;
     this.currentMember = assignment.Member;
     Expression e = this.Visit(assignment.Expression);
     this.currentMember = saveMember;
     return this.UpdateMemberAssignment(assignment, assignment.Member, e);
 }
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            var constantValue = node.Expression as ConstantExpression;
            if (constantValue != null)
            {
                _updateBuilder.Set(String.Join(".", _assigments.Reverse().ToArray()), BsonValue.Create(constantValue.Value));
            }
            else
            {
                return base.VisitMemberAssignment(node);
            }

            return node;
        }
 protected override void VisitMemberAssignment(MemberAssignment assignment)
 {
     Print("{0} = ", assignment.Member.Name);
     Visit(assignment.Expression);
 }
        /// <summary>
        /// Visit a member assignment expression.
        /// </summary>
        /// <param name="assignmentExp"></param>
        /// <returns></returns>
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignmentExp)
        {
            Expression e = Visit(assignmentExp.Expression);

            return e != assignmentExp.Expression ? Expression.Bind(assignmentExp.Member, e) : assignmentExp;
        }
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     System.Linq.Expressions.Expression e = Visit(assignment.Expression);
     if(e != assignment.Expression)
     {
         return System.Linq.Expressions.Expression.Bind(assignment.Member, e);
     }
     return assignment;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Visit a member assignment expression.
        /// </summary>
        /// <param name="assignmentExp"></param>
        /// <returns></returns>
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignmentExp)
        {
            Expression e = Visit(assignmentExp.Expression);

            if (e != assignmentExp.Expression)
            {
                return Expression.Bind(assignmentExp.Member, e);
            }

            return assignmentExp;
        }
Ejemplo n.º 12
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     return((MemberAssignment)null);
 }
Ejemplo n.º 13
0
 internal virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     Expression expression = this.Visit(assignment.Expression);
     if (expression == assignment.Expression)
     {
         return assignment;
     }
     return Expression.Bind(assignment.Member, expression);
 }
        /// <summary>
        /// Makes a member binding slim object representing a MemberAssignment with the given children.
        /// </summary>
        /// <param name="node">Original member assignment.</param>
        /// <param name="expression">Assigned expression slim.</param>
        /// <returns>Slim representation of the original member assignment.</returns>
        protected override MemberAssignmentSlim MakeMemberAssignment(MemberAssignment node, ExpressionSlim expression)
        {
            var member = MakeMember(node.Member);

            return(_factory.Bind(member, expression));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Visits the children of the <c>MemberAssignment</c>.
        /// </summary>
        /// <param name="assignment">The expression to visit.</param>
        /// <returns>The modified expression, if it or any subexpression was modified; 
        /// otherwise, returns the original expression.</returns>
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            if (assignment == null)
                throw new ArgumentNullException("assignment");

            var e = Visit(assignment.Expression);
            return e == assignment.Expression ? assignment : Expression.Bind(assignment.Member, e);
        }
Ejemplo n.º 16
0
		protected override void VisitMemberAssignment (MemberAssignment assignment)
		{
			Visit (assignment.Expression);

			var value = Pop ();

			assignment.Member.OnFieldOrProperty (
				field => {
					object target = null;
					if (!field.IsStatic)
						target = Pop ();

					field.SetValue (target, value);

					if (!field.IsStatic)
						Push (target);
				},
				property => {
					object target = null;
					var getter = property.GetGetMethod (true);
					if (!getter.IsStatic)
						target = Pop ();

					property.SetValue (target, value, null);

					if (!getter.IsStatic)
						Push (target);
				});
		}
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            var expression = this.Visit(node.Expression);

            return(UpdateMemberAssignment(node, node.Member, expression));
        }
 protected virtual new MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     return(default(MemberAssignment));
 }
Ejemplo n.º 19
0
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            var e = Visit(assignment.Expression);

            return(e != assignment.Expression ? Expression.Bind(assignment.Member, e) : assignment);
        }
Ejemplo n.º 20
0
 protected virtual bool VisitMemberAssignment(MemberAssignment assignment, MemberAssignment assignment2)
 {
     return(assignment.Member == assignment2.Member &&
            Visit(assignment.Expression, assignment2.Expression));
 }
Ejemplo n.º 21
0
        protected virtual new MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            Contract.Requires(node != null);

            return(default(MemberAssignment));
        }
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment, Stack<string> stack, Stack<IElasticPropertyAttribute> properties)
 {
     Expression e = this.Visit(assignment.Expression, stack, properties);
     if (e != assignment.Expression)
     {
         return Expression.Bind(assignment.Member, e);
     }
     return assignment;
 }
 public MemberAssignmentNode(INodeFactory factory, MemberAssignment memberAssignment)
     : base(factory, memberAssignment.BindingType, memberAssignment.Member)
 {
     this.Expression = this.Factory.Create(memberAssignment.Expression);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Visits a MemberAssignment.
 /// </summary>
 /// <param name="node">The MemberAssignment.</param>
 /// <returns>The MemberAssignment (possibly modified).</returns>
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     Expression e = Visit(node.Expression);
     return UpdateMemberAssignment(node, node.Member, e);
 }
 protected override MemberBinding VisitMemberAssignment(MemberAssignment memberAssigment)
 {
     CheckAndVisitMemberAssignment (memberAssigment.Member, memberAssigment.Expression);
       return memberAssigment;
 }
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment expression)
        {
            MemberAssignment current;
            if (!TryGetCurrent(expression, out current))
            {
                return expression;
            }

            if (!(this.result &= current.BindingType == expression.BindingType))
            {
                return expression;
            }

            if (!(this.result &= object.Equals(current.Member, expression.Member)))
            {
                return expression;
            }

            this.currentObject = current.Expression;
            this.Visit(expression.Expression);
            if (!this.result)
            {
                return expression;
            }

            this.currentObject = current;
            return expression;
        }
Ejemplo n.º 27
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 28
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     var e = Visit(assignment.Expression);
     return e != assignment.Expression ? Expression.Bind(assignment.Member, e) : assignment;
 }
Ejemplo n.º 29
0
 protected virtual void VisitMemberAssignment(MemberAssignment assignment)
 {
     Visit(assignment.Expression);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Constructor with an <see cref="MemberAssignment"/> and an <see cref="ExpressionConverter"/>.
 /// </summary>
 /// <param name="memberAssignment">The original, not serializable <see cref="MemberBinding"/>.</param>
 /// <param name="expConverter">The <see cref="ExpressionConverter"/> to convert contained <see cref="Expression">Expressions</see>.</param>
 public SerializableMemberAssignment(MemberAssignment memberAssignment, ExpressionConverter expConverter)
     : base(memberAssignment, expConverter)
 {
     Expression = memberAssignment.Expression.MakeSerializable(expConverter);
 }
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
        {
            var expr = Visit(node.Expression);

            return(PushBinding(node, new XAttribute(nameof(node.Member), node.Member), new XElement(nameof(node.Expression), expr)));
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Visits the children of the <see cref="MemberAssignment"/>.
 /// </summary>
 /// <param name="node">The expression to visit.</param>
 /// <returns>The modified expression, if it or any subexpression was modified;
 /// otherwise, returns the original expression.</returns>
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     return(node.Update(Visit(node.Expression)));
 }
Ejemplo n.º 33
0
 protected virtual bool CompareMemberAssignment(MemberAssignment a, MemberAssignment b)
 {
     return a.Member == b.Member
         && this.Compare(a.Expression, b.Expression);
 }
 /// <summary>
 /// Visits a MemberAssignment.
 /// </summary>
 /// <param name="node">The MemberAssignment.</param>
 /// <returns>The MemberAssignment.</returns>
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     _sb.Append("<MemberAssignment>");
     return node;
 }
Ejemplo n.º 35
0
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     this.Write(assignment.Member.Name);
     this.Write(" = ");
     this.Visit(assignment.Expression);
     return assignment;
 }
 /// <summary>
 /// MemberAssignment visit method
 /// </summary>
 /// <param name="assignment">The MemberAssignment to visit</param>
 /// <returns>The visited MemberAssignmentt</returns>
 internal override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     this.Visit(assignment.Expression);
     return assignment;
 }
Ejemplo n.º 37
0
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment) => InvokeEvent(MemberAssignmentVisited, assignment, base.VisitMemberAssignment);
Ejemplo n.º 38
0
        /*protected virtual void JoinRootExpressions()
        {
        }*/

        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            Expression e = this.Visit(assignment.Expression);
            return this.UpdateMemberAssignment(assignment, assignment.Member, e);
        }
    public virtual bool IsEvaluatableMemberAssignment (MemberAssignment node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
Ejemplo n.º 40
0
 private static MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 41
0
 public EditableMemberAssignment(MemberAssignment member)
     : base(member.BindingType, member.Member)
 {
     Expression = EditableExpression.Create(member.Expression);
 }
 /// <summary>
 /// Visits a MemberAssignment.
 /// </summary>
 /// <param name="node">The MemberAssignment.</param>
 /// <returns>The MemberAssignment.</returns>
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     throw new NotImplementedException();
 }
        protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            this.Visit(assignment.Expression);

            switch (assignment.Member.MemberType)
            {
                case MemberTypes.Field:
                    Console.WriteLine("stfld " + assignment.Member);
                    generator.Emit(OpCodes.Stfld, (FieldInfo)assignment.Member);
                    break;
                case MemberTypes.Property:
                    var method = ((PropertyInfo)assignment.Member).GetSetMethod();
                    Console.WriteLine("callvirt {0} {1}", method.DeclaringType.Name, method.Name);
                    generator.Emit(OpCodes.Callvirt, ((PropertyInfo)assignment.Member).GetSetMethod());
                    break;
                default:
                    throw new NotSupportedException("Unsupported member assignment type: " + assignment.Member.MemberType);
            }

            return assignment;
        }
 /// <summary>
 /// Visits a MemberAssignment.
 /// </summary>
 /// <param name="assignment">The MemberAssignment.</param>
 /// <returns>The MemberAssignment (possibly modified).</returns>
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     Expression e = this.Visit(assignment.Expression);
     if (e != assignment.Expression)
     {
         return Expression.Bind(assignment.Member, e);
     }
     return assignment;
 }
Ejemplo n.º 45
0
        private MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            var e = Visit(assignment.Expression);

            return(e != assignment.Expression ? Expression.Bind(assignment.Member, e) : assignment);
        }