Example #1
0
        public static Expression MakeMemberAccess(Expression instance, string memberName)
        {
            foreach (var token in MemberAccessTokenizer.GetTokens(memberName))
            {
                instance = token.CreateMemberAccessExpression(instance);
            }

            return(instance);
        }
        public override Expression CreateMemberAccessExpression()
        {
            //if no property specified then return the item itself
            if (string.IsNullOrEmpty(MemberName))
            {
                return(this.ParameterExpression);
            }

            Expression instance = ParameterExpression;

            foreach (var token in MemberAccessTokenizer.GetTokens(MemberName))
            {
                if (token is PropertyToken)
                {
                    var propertyName = ((PropertyToken)token).PropertyName;
                    instance = CreatePropertyAccessExpression(instance, propertyName);
                }
                else if (token is IndexerToken)
                {
                    instance = CreateIndexerAccessExpression(instance, (IndexerToken)token);
                }
            }
            return(instance);
        }