Represents assignment to a member of an object.
Inheritance: MemberBinding
コード例 #1
0
ファイル: FieldsFormater.cs プロジェクト: yaozd/YOYOFx
        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;
        }
コード例 #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;
 }
コード例 #3
0
		protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
		{
			this.output.Append(assignment.Member.Name).Append(" = ");
			this.Visit(assignment.Expression);

			return assignment;
		}
コード例 #4
0
ファイル: UpdateCollector.cs プロジェクト: jefth/EasyMongo
        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;
        }
コード例 #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);
 }
コード例 #7
0
        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;
        }
コード例 #8
0
 protected override void VisitMemberAssignment(MemberAssignment assignment)
 {
     Print("{0} = ", assignment.Member.Name);
     Visit(assignment.Expression);
 }
コード例 #9
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);

            return e != assignmentExp.Expression ? Expression.Bind(assignmentExp.Member, e) : assignmentExp;
        }
コード例 #10
0
 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;
 }
コード例 #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;
        }
コード例 #12
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     return((MemberAssignment)null);
 }
コード例 #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);
 }
コード例 #14
0
        /// <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));
        }
コード例 #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);
        }
コード例 #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);
				});
		}
コード例 #17
0
        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));
 }
コード例 #19
0
        protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            var e = Visit(assignment.Expression);

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

            return(default(MemberAssignment));
        }
コード例 #22
0
 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;
 }
コード例 #23
0
 public MemberAssignmentNode(INodeFactory factory, MemberAssignment memberAssignment)
     : base(factory, memberAssignment.BindingType, memberAssignment.Member)
 {
     this.Expression = this.Factory.Create(memberAssignment.Expression);
 }
コード例 #24
0
ファイル: ExpressionVisitor.cs プロジェクト: sprucemedia/oinq
 /// <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);
 }
コード例 #25
0
 protected override MemberBinding VisitMemberAssignment(MemberAssignment memberAssigment)
 {
     CheckAndVisitMemberAssignment (memberAssigment.Member, memberAssigment.Expression);
       return memberAssigment;
 }
コード例 #26
0
        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;
        }
コード例 #27
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     var e = Visit(assignment.Expression);
     return e != assignment.Expression ? Expression.Bind(assignment.Member, e) : assignment;
 }
コード例 #29
0
 protected virtual void VisitMemberAssignment(MemberAssignment assignment)
 {
     Visit(assignment.Expression);
 }
コード例 #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);
 }
コード例 #31
0
        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)));
        }
コード例 #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)));
 }
コード例 #33
0
 protected virtual bool CompareMemberAssignment(MemberAssignment a, MemberAssignment b)
 {
     return a.Member == b.Member
         && this.Compare(a.Expression, b.Expression);
 }
コード例 #34
0
 /// <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;
 }
コード例 #35
0
ファイル: ExpressionWriter.cs プロジェクト: PaybackMan/Cinder
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
 {
     this.Write(assignment.Member.Name);
     this.Write(" = ");
     this.Visit(assignment.Expression);
     return assignment;
 }
コード例 #36
0
 /// <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;
 }
コード例 #37
0
 protected override MemberAssignment VisitMemberAssignment(MemberAssignment assignment) => InvokeEvent(MemberAssignmentVisited, assignment, base.VisitMemberAssignment);
コード例 #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);
        }
コード例 #39
0
    public virtual bool IsEvaluatableMemberAssignment (MemberAssignment node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
コード例 #40
0
 private static MemberAssignment VisitMemberAssignment(MemberAssignment node)
 {
     throw new NotImplementedException();
 }
コード例 #41
0
 public EditableMemberAssignment(MemberAssignment member)
     : base(member.BindingType, member.Member)
 {
     Expression = EditableExpression.Create(member.Expression);
 }
コード例 #42
0
 /// <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;
        }
コード例 #44
0
 /// <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;
 }
コード例 #45
0
        private MemberAssignment VisitMemberAssignment(MemberAssignment assignment)
        {
            var e = Visit(assignment.Expression);

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