反复向C#类属性添加事件侦听器

时间:2017-05-08 20:54:40

标签: c# linq linq-to-sql

我正在尝试创建一个OleTableAttribute,我会将MyTableSystem.Data.Linq.Mapping.TableAttribute一起应用于[Table(Name="MyTable")] [OleTable] public class MyTable { [Column(IsPrimaryKey = true)] public int pk_id { get; set; } /*...*/ } ,以便它看起来像这样:

OleTableAttribute

我希望[Column]要做的是查找标记在其中的类中的任何public IEnumerable<DateTime> GetMonths(DateTime startDate, DateTime endDate) { if(startDate > endDate) { throw new ArgumentException( $"{nameof(startDate)} cannot be after {nameof(endDate)}"); } startDate = new DateTime(startDate.Year, startDate.Month, 1); while (startDate <= endDate) { yield return startDate; startDate = startDate.AddMonths(1); } } 属性属性,并反复向setter方法添加某种类型的侦听器它有一个。这个问题的重点是如何进行二次调用的反射监控设置;只是一个简单的&#34;嘿,它被称为&#34;信号就是我所需要的。这可能吗?

1 个答案:

答案 0 :(得分:0)

PostSharp有效。使用[NotifyPropertyChanged]方面将使用我正在寻找的信令类型来装饰幕后的所有属性。然后,[OleTable]可以将其视为属性类as INotifyPropertyChanged,并添加自己的PropertyChanged事件。

相关问题