main
 1using System;
 2using System.Linq.Expressions;
 3using System.Reflection;
 4using gorilla.commons.utility;
 5
 6namespace MoMoney.Presentation.Winforms.Databinding
 7{
 8    public interface IPropertyInspector<TypeToBindTo, TypeOfProperty>
 9    {
10        PropertyInfo inspect(Expression<Func<TypeToBindTo, TypeOfProperty>> property_to_bind_to);
11    }
12
13    public class PropertyInspector<TypeToBindTo, TypeOfProperty> : IPropertyInspector<TypeToBindTo, TypeOfProperty>
14    {
15        public PropertyInfo inspect(Expression<Func<TypeToBindTo, TypeOfProperty>> property_to_bind_to)
16        {
17            var expression = property_to_bind_to.Body.downcast_to<MemberExpression>();
18            return expression.Member.downcast_to<PropertyInfo>();
19        }
20    }
21}