Ejemplo n.º 1
0
        private DynamicMetaObject DoBindSetMember(ExpressionContainer wrapper, Type returnType, string memberName, bool ignoreCase, DynamicMetaObject value)
        {
            var valueExpr = wrapper.Expression;
            var property  = MockingUtil.ResolveProperty(valueExpr.Type, memberName, ignoreCase, new object[0], !wrapper.IsStatic, value.Value, getter: false);

            if (property == null)
            {
                ThrowMissingMemberException(valueExpr.Type, memberName);
            }

            var memberExpr = Expression.Assign(Expression.Property(!wrapper.IsStatic ? valueExpr : null, property), FromArg(value));

            return(CreateRecorder(memberExpr, returnType, BindingRestrictions.GetInstanceRestriction(this.Expression, this.Value)));
        }
Ejemplo n.º 2
0
        public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
        {
            if (binder.Operation == ExpressionType.Equal)
            {
                var wrapper   = this.Value as ExpressionContainer;
                var valueExpr = wrapper.Expression as MemberExpression;
                if (valueExpr != null)
                {
                    var prevContainer = new ExpressionContainer(valueExpr.Expression)
                    {
                        IsStatic = ((PropertyInfo)valueExpr.Member).GetGetMethod(true).IsStatic
                    };
                    return(DoBindSetMember(prevContainer, binder.ReturnType, valueExpr.Member.Name, false, arg));
                }
            }

            return(base.BindBinaryOperation(binder, arg));
        }
Ejemplo n.º 3
0
		private DynamicMetaObject DoBindSetMember(ExpressionContainer wrapper, Type returnType, string memberName, bool ignoreCase, DynamicMetaObject value)
		{
			var valueExpr = wrapper.Expression;
			var property = PrivateAccessor.ResolveProperty(valueExpr.Type, memberName, ignoreCase, new object[0], !wrapper.IsStatic, value.Value, getter: false);
			if (property == null)
				ThrowMissingMemberException(valueExpr.Type, memberName);

			var memberExpr = Expression.Assign(Expression.Property(!wrapper.IsStatic ? valueExpr : null, property), FromArg(value));

			return CreateRecorder(memberExpr, returnType);
		}
Ejemplo n.º 4
0
		public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg)
		{
			if (binder.Operation == ExpressionType.Equal)
			{
				var wrapper = this.Value as ExpressionContainer;
				var valueExpr = wrapper.Expression as MemberExpression;
				if (valueExpr != null)
				{
					var prevContainer = new ExpressionContainer(valueExpr.Expression) { IsStatic = ((PropertyInfo)valueExpr.Member).GetGetMethod(true).IsStatic };
					return DoBindSetMember(prevContainer, binder.ReturnType, valueExpr.Member.Name, false, arg);
				}
			}

			return base.BindBinaryOperation(binder, arg);
		}