TinyEE.DLRUtil.GetFieldPropertyBinder C# (CSharp) Method

GetFieldPropertyBinder() public static method

public static GetFieldPropertyBinder ( string name ) : System.Runtime.CompilerServices.CallSiteBinder
name string
return System.Runtime.CompilerServices.CallSiteBinder
        public static CallSiteBinder GetFieldPropertyBinder(string name)
        {
            return Binder.GetMember(CSharpBinderFlags.None, name, null, GetArgInfo(1));
        }

Usage Example

Exemplo n.º 1
0
        private static Expression GetMemberExpression(IList <ParseNode> nodes, int start, Expression context)
        {
            Debug.Assert(nodes.Count >= 3 && nodes.Count % 2 == 1);
            Expression result;

            if (start == 0)
            {
                result = GetInnerAST(nodes, context);
            }
            else
            {
                var @operator = nodes[start - 1].Token;
                var baseExpr  = GetMemberExpression(nodes, start - 2, context);
                if (@operator.Type == TokenType.DOT)
                {
                    var child = nodes[start].Nodes[0];
                    if (child.Token.Type == TokenType.FunctionCall)
                    {
                        result = GetFunctionAST(child.Nodes, baseExpr, false, context);
                    }
                    else if (child.Token.Type == TokenType.IDENTIFIER)
                    {
                        var fieldName = nodes[start].Nodes[0].Token.Text;
                        result = Expression.Dynamic(DLRUtil.GetFieldPropertyBinder(fieldName), typeof(object), baseExpr);
                    }
                    else
                    {
                        throw new InvalidOperationException("Invalid children, expect either Property or Method call at this point");
                    }
                }
                else if (@operator.Type == TokenType.LBRACKET)
                {
                    var indexExpr = nodes[start].GetAST(context);
                    result = Expression.Dynamic(DLRUtil.GetIndexBinder(),
                                                typeof(object),
                                                baseExpr,
                                                indexExpr);
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            return(result);
        }