是否有人编写了实现 INotifyCollectionChanged 的 .Net 通用队列版本,或者是否已经在 .Net 框架深处隐藏了某个版本?
快速搜索没有显示任何结果。但接口很简单,扩展 Queue 类并添加对该接口的支持几乎是微不足道的。只需重写所有方法即可:
// this isn't the best code ever; refactor as desired
protected void OnCollectionChanged( NotifyCollectionChangedEventArgs ccea){
var temp = CollectionChanged;
if(temp != null) temp(this, ccea);
}
// and later in the class
public override SomeMethodThatAltersTheQueue(object something){
// record state of collection prior to change
base.SomeMethodThatAltersTheQueue(something)
// create NotifyCollectionChangedEventArgs with prior state and new state
OnCollectionChanged(ccea);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)