public object GetValue(Expression expression)
        {
            var mi = (MemberInitExpression)expression;

            var obj = ExpressionValueProvidingTools.GetValue(mi.NewExpression);

            foreach (var memberBinding in mi.Bindings)
            {
                if (memberBinding.BindingType != MemberBindingType.Assignment)
                {
                    throw new NotSupportedException($"Member binding type '{memberBinding.BindingType}' not supported");
                }
                var ma          = (MemberAssignment)memberBinding;
                var memberValue = ExpressionValueProvidingTools.GetValue(ma.Expression);

                switch (memberBinding.Member.MemberType)
                {
                case MemberTypes.Field:
                    ((FieldInfo)memberBinding.Member).SetValue(obj, memberValue);
                    break;

                case MemberTypes.Property:
                    ((PropertyInfo)memberBinding.Member).SetValue(obj, memberValue);
                    break;

                default:
                    throw new NotSupportedException($"Member type '{memberBinding.Member.MemberType}' not supported");
                }
            }

            return(obj);
        }
        public object GetValue(Expression expression)
        {
            var call = ((MethodCallExpression)expression);

            var targetObject = call.Object != null
                ? ExpressionValueProvidingTools.GetValue(call.Object)
                : null;

            var args = call.Arguments
                       .Select(ExpressionValueProvidingTools.GetValue)
                       .ToArray();

            return(call.Method.Invoke(targetObject, args));
        }
        public object GetValue(Expression expression)
        {
            var ma = (MemberExpression)expression;

            var targetObject = ExpressionValueProvidingTools.GetValue(ma.Expression);

            switch (ma.Member.MemberType)
            {
            case MemberTypes.Field:
                return(((FieldInfo)ma.Member).GetValue(targetObject));

            case MemberTypes.Method:
                return(((PropertyInfo)ma.Member).GetValue(targetObject));

            case MemberTypes.Property:
                return(((PropertyInfo)ma.Member).GetValue(targetObject));

            default:
                throw new NotSupportedException($"Member access '{ma.Member.MemberType}' not supported");
            }
        }
        public object GetValue(Expression expression)
        {
            var uExpr = (UnaryExpression)expression;

            return(ExpressionValueProvidingTools.GetValue(uExpr.Operand));
        }
 public object GetValue()
 {
     return(ExpressionValueProvidingTools.GetValue(_valueProviderExpression));
 }