没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
oss.trustie.net/open_source_projects | 主页 > 开源项目社区 > easyprop |
easyprop
|
0 | 0 | 57 |
贡献者 | 讨论 | 代码提交 |
EasyProp helps you replace repetetive code like:
public class Foo : INotifyPropertyChanged
{
public string Bar
{
get{ return _bar; }
set
{
if (_bar != value)
{
_bar = value;
OnNotifyPropertyChanged(new PropertyChangedEventArgs("Bar"));
}
}
}
...repeat for every property
}... with:
[BeforePropertySetFilter(typeof(DoNothingIfValueNotChanged))]
[AfterPropertySetFilter(typeof(NotifyPropertyChanged))]
public class Foo : INotifyPropertyChanged
{
public virtual string Bar { get; set; }
...
}There are other filters available, and you can write your own:
[BeforePropertySetFilter(typeof(DoNothingIfValueNotChanged))]
[AfterPropertySetFilter(typeof(MarkObjectAsDirty))]
public class Foo
{
public virtual bool IsDirty { get; set; }
public virtual string Bar { get; set; }
}Just mark your properties as virtual, and let EasyProp build your objects:
EasyPropBuilder easyPropBuilder = new EasyPropBuilder();
Foo myFoo = easyPropBuilder.Build();EasyProp uses Castle DynamicProxy internally to do the property intercepting. It's merged into EasyProp binaries, so you only need to reference EasyProp.dll.
These blog posts were helpful for the development of EasyProp:
http://serialseb.blogspot.com/2008/05/implementing-inotifypropertychanged.html
http://hendryluk.wordpress.com/2008/05/28/roll_your_own_cop_part_i_mixins/
Thanks to Frank Quednau, EasyProp 1.1 handles databinding in WPF properly.