/// <summary> /// Создается геттер. /// </summary> /// <param name="property_info"></param> /// <returns></returns> private Func <T, IValue> CreateGetter(PropertyInfo property_info) { ParameterExpression instance_parameter = Expression.Parameter(typeof(T), "target"); var getter = property_info.GetGetMethod(); Expression call = Expression.Call(instance_parameter, getter); Expression result = ConvertExpression.ConvertToScript(getter.ReturnType, call); return(Expression.Lambda <Func <T, IValue> >(result, instance_parameter).Compile()); }
/// <summary> /// Создает прототип функции. /// </summary> /// <param name="method"></param> /// <returns></returns> private Func <T, IVariable[], IValue> CreateFunction(MethodInfo method) { ParameterExpression instanceParameter = Expression.Parameter(typeof(T), "target"); ParameterExpression argumentsParameter = Expression.Parameter(typeof(IVariable[]), "arguments"); Expression call; if (!method.IsStatic) { call = Expression.Call(instanceParameter, method, CreateParameterExpressions(method, argumentsParameter)); } else { call = Expression.Call(method, CreateParameterExpressions(method, argumentsParameter)); } Expression result = ConvertExpression.ConvertToScript(method.ReturnType, call); return(Expression.Lambda <Func <T, IVariable[], IValue> >(result, instanceParameter, argumentsParameter).Compile()); }