title: Reflection vs. Compile To Get The Value Of MemberExpression
body: <p>How can I achieve this without using Compile() but just with normal reflection?</p>
  
  <pre><code>var value = Expression.Lambda(memberExpression).Compile().DynamicInvoke();
  </code></pre>
  
  <p>I want this to be able to run on an IPhone (MonoTouch), which does not allow dynamic compiling.</p>
  
  <p>UPDATE: Here is more context.  This is the code I am working on:</p>
  
  <pre><code>if (expression.Expression is ConstantExpression)
  {
   var constantExpression = (ConstantExpression)expression.Expression;
   var fieldInfo = constantExpression.Value.GetType().GetField(expression.Member.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
   if (fieldInfo != null)
   {
    return fieldInfo.GetValue(constantExpression.Value);
   }
   {
    var propertyInfo = constantExpression.Value.GetType().GetProperty(expression.Member.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
    if (propertyInfo != null)
    {
     return propertyInfo.GetValue(constantExpression.Value, null);
    }
   }
  }
  else
  {
   return Expression.Lambda(expression.Expression).Compile().DynamicInvoke();
  }
  </code></pre>
  
  <p>As you can see, the code in the if block uses no runtime compilation to obtain the value.  My goal is that the code in the in the else block <strong>not</strong> use runtime compilation either.</p>