Ejemplo n.º 1
0
        public static object Execute(Expression expr)
        {
            switch (expr)
            {
            case ConstantExpression ce:
                return(ce.Value);

            case MemberExpression me:
                var owner = Execute(me.Expression);
                return(GetValue(me.Member, owner));

            default:
                throw PtixedException.InvalidExpression(expr);
            }
        }
Ejemplo n.º 2
0
        public static object GetValue(MemberInfo member, object owner)
        {
            var accessor = TypeAccessor.Get(member.DeclaringType);

            switch (member)
            {
            case FieldInfo fi:
                return(accessor[owner, fi]);

            case PropertyInfo pi:
                return(accessor[owner, pi]);

            default:
                throw PtixedException.InvalidExpression(member);
            }
        }