Ejemplo n.º 1
0
        public ExpressionTransformer(MethodParser methodParser)
        {
            MethodParser = methodParser;

            int argumentIndex = 0;
            var parameters    = methodParser.MethodInfo.GetParameters();

            if (!methodParser.MethodInfo.IsStatic)
            {
                argumentIndex = 1;
            }

            _arguments = new Expression[parameters.Length + argumentIndex];
            foreach (var parameterInfo in methodParser.MethodInfo.GetParameters())
            {
                _arguments[argumentIndex++] = Expression.Variable(parameterInfo.ParameterType);
            }

            var localVariables = methodParser.MethodInfo.GetMethodBody().LocalVariables;

            _variables = new Expression[localVariables.Count];
            for (var i = 0; i < _variables.Length; ++i)
            {
                _variables[localVariables[i].LocalIndex] = Expression.Variable(localVariables[i].LocalType);
            }

            _branchBuilder   = new BranchBuilder();
            _evaluationStack = new Stack <object>();
        }
Ejemplo n.º 2
0
        public PropertyParser(PropertyInfo propInfo)
        {
            PropertyInfo = propInfo;

            if (propInfo.GetGetMethod() != null)
            {
                Getter = new MethodParser(propInfo.GetGetMethod());
            }

            if (propInfo.GetSetMethod() != null)
            {
                Setter = new MethodParser(propInfo.GetSetMethod());
            }
        }