示例#1
0
 /// <summary>
 /// Cria o acesso do membro.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="memberName"></param>
 /// <returns></returns>
 public static Expression MakeMemberAccess(Expression instance, string memberName)
 {
     foreach (IMemberAccessToken token in MemberAccessTokenizer.GetTokens(memberName))
     {
         instance = token.CreateMemberAccessExpression(instance);
     }
     return(instance);
 }
        /// <summary>
        /// Cria a expressão para acesso ao membro.
        /// </summary>
        /// <returns></returns>
        public override Expression CreateMemberAccessExpression()
        {
            if (string.IsNullOrEmpty(base.MemberName))
            {
                return(base.ParameterExpression);
            }
            Expression parameterExpression = base.ParameterExpression;

            foreach (IMemberAccessToken token in MemberAccessTokenizer.GetTokens(base.MemberName))
            {
                if (token is PropertyToken)
                {
                    string propertyName = ((PropertyToken)token).PropertyName;
                    parameterExpression = this.CreatePropertyAccessExpression(parameterExpression, propertyName);
                }
                else if (token is IndexerToken)
                {
                    parameterExpression = this.CreateIndexerAccessExpression(parameterExpression, (IndexerToken)token);
                }
            }
            return(parameterExpression);
        }