Exemplo n.º 1
0
        public override IObjectState UpdateImpl(IObjectDataMember objectDataMember)
        {
            var tabExpression  = Constant(Tab);
            var callExpression = MakeIndentExpression(Call(StringConcat2StringsMethod, tabExpression,
                                                           Call(objectDataMember.GetValueExpression(_Target), GetToStringMethodInfo(objectDataMember))));
            Expression memberNameExpression = Constant(objectDataMember.MemberName + " :");
            var        endOfLineExpression  = Constant(NewLine);
            var        typeExpression       = objectDataMember.Walker.CanExpand(objectDataMember.MemberType) && Nullable.GetUnderlyingType(objectDataMember.MemberType) == null
                ? Call(StringConcat2StringsMethod, Constant($"{Tab}<{objectDataMember.MemberType.Name}>"), endOfLineExpression)
                : null;

            if (typeExpression != null)
            {
                memberNameExpression = Call(StringConcat2StringsMethod, memberNameExpression, typeExpression);
            }

            if (Nullable.GetUnderlyingType(objectDataMember.MemberType) != null || !objectDataMember.MemberType.IsValueType)
            {
                callExpression = Condition(NotEqual(objectDataMember.GetValueExpression(_Target),
                                                    Constant(null, objectDataMember.MemberType)), callExpression, Constant($"{Tab}(null){NewLine}"));
            }
            var lineExpression        = Call(StringConcat2StringsMethod, memberNameExpression, callExpression);
            var concatLinesExpression = Call(StringConcat2StringsMethod, _Expression, lineExpression);

            return(new ToStringObjectState(concatLinesExpression, _Target));
        }
Exemplo n.º 2
0
        public override IObjectState UpdateImpl(IObjectDataMember objectDataMember)
        {
            var targetMember = objectDataMember.GetValueExpression(_target);
            var leftMember   = objectDataMember.GetValueExpression(_left);
            var rightMember  = objectDataMember.GetValueExpression(_right);

            var test   = Expression.NotEqual(Expression.Default(objectDataMember.MemberType), leftMember);
            var assign = Expression.Assign(targetMember, Expression.Condition(test, leftMember, rightMember));

            _expressions.Add(assign);

            return(new MergeObjectState(_expressions, _target, _left, _right, _type));
        }
Exemplo n.º 3
0
        public override IObjectState UpdateImpl(IObjectDataMember objectDataMember)
        {
            Expression callExpression = Expression.Call(objectDataMember.GetValueExpression(_Target), GetHashCodeMethodInfo(objectDataMember));

            if (Nullable.GetUnderlyingType(objectDataMember.MemberType) != null || !objectDataMember.MemberType.IsValueType)
            {
                callExpression = Expression.Condition(Expression.NotEqual(objectDataMember.GetValueExpression(_Target),
                                                                          Expression.Constant(null, objectDataMember.MemberType)), callExpression, Expression.Constant(0));
            }
            var multExpression = Expression.Multiply(_Expression, Expression.Constant(23));
            var addExpression  = Expression.Add(multExpression, callExpression);

            return(new GetHashCodeObjectState(addExpression, _Target));
        }
        public override IObjectState UpdateImpl(IObjectDataMember objectDataMember)
        {
            var eqExpression = Expression.Equal(objectDataMember.GetValueExpression(_left), objectDataMember.GetValueExpression(_right));
            var result       = Expression.AndAlso(_expression, eqExpression);

            return(new EqualityObjectState(result, _left, _right));
        }