Archive for April, 2009

Hello world!

2009-04-28

Testing source code:

class ReflectionUtility
 {

 public static string GetPropertyName<T, TReturn>(Expression<Func<T, TReturn>> expression)
 {
 MemberExpression body = (MemberExpression)expression.Body;
 return body.Member.Name;
 }

 public static string GetMethodName<T, TReturn>(Expression<Func<T, TReturn>> expression)
 {
 var body = expression.Body as UnaryExpression;
 var operand = body.Operand as MethodCallExpression;
 var argument = operand.Arguments[2] as ConstantExpression;
 var methodInfo = argument.Value as System.Reflection.MethodInfo;

 return methodInfo.Name;
 }

 }