@280Z28 - We were just sitting down to figure out how to do this when I found your question & code. We needed a PropertyOf method so I added it. Here it is in case anybody else needs it. Thx for the great question.
public static PropertyInfo PropertyOf(Expression> expression)
{
MemberExpression body = (MemberExpression)expression.Body;
PropertyInfo pi = body.Member as PropertyInfo;
if (pi != null)
{
return pi;
}
else throw new ArgumentException("Lambda must be a Property.");
}
[TestMethod()]
public void MethodofPropertyOfTest()
{
string foo = "Jamming";
MethodInfo method1 = ReflectionHelper.Methodof(() => default(string).ToString());
PropertyInfo prop = ReflectionHelper.PropertyOf(() => default(string).Length);
Assert.AreEqual(method1.Invoke(foo, null), "Jamming");
Assert.AreEqual(prop.GetGetMethod().Invoke(foo, null), foo.Length);
}