main
1using System.Reflection;
2
3namespace MoMoney.Presentation.Winforms.Databinding
4{
5 public interface IPropertyBinder<TypeToBindTo, PropertyType>
6 {
7 TypeToBindTo target { get; }
8 PropertyInfo property { get; }
9 PropertyType current_value();
10 void change_value_of_property_to(PropertyType new_value);
11 }
12
13 public class PropertyBinder<TypeToBindTo, PropertyType> : IPropertyBinder<TypeToBindTo, PropertyType>
14 {
15 public PropertyBinder(PropertyInfo propery_information, TypeToBindTo target)
16 {
17 property = target.GetType().GetProperty(propery_information.Name);
18 this.target = target;
19 }
20
21 public TypeToBindTo target { get; private set; }
22 public PropertyInfo property { get; private set; }
23
24 public PropertyType current_value()
25 {
26 return (PropertyType) property.GetValue(target, null);
27 }
28
29 public void change_value_of_property_to(PropertyType value)
30 {
31 property.SetValue(target, value, null);
32 }
33 }
34}