Antlr4.StringTemplate.Misc.ObjectModelAdaptor.BuildAccessor C# (CSharp) Метод

BuildAccessor() приватный статический Метод

Builds an accessor for an indexer property that returns a takes a string argument.
private static BuildAccessor ( System.Reflection.MethodInfo method, string argument ) : object>.System.Func
method System.Reflection.MethodInfo
argument string
Результат object>.System.Func
        private static System.Func<object, object> BuildAccessor(MethodInfo method, string argument)
        {
            ParameterExpression obj = Expression.Parameter(typeof(object), "obj");
            UnaryExpression instance = !method.IsStatic ? Expression.Convert(obj, method.DeclaringType) : null;
            Expression<System.Func<object, object>> expr = Expression.Lambda<System.Func<object, object>>(
                Expression.Convert(
                    Expression.Call(instance, method, Expression.Constant(argument)),
                    typeof(object)),
                obj);

            return expr.Compile();
        }

Same methods

ObjectModelAdaptor::BuildAccessor ( System.Reflection.FieldInfo field ) : object>.System.Func
ObjectModelAdaptor::BuildAccessor ( System.Reflection.MethodInfo method ) : object>.System.Func