【发布时间】:2010-07-07 12:19:46
【问题描述】:
我有一个定义为 IStore 的接口,有两种方法:
public interface IStore<TEntity>
{
TEntity Get(object identifier);
void Put(TEntity entity);
}
我希望在 Put 成功时引发事件 (作为参考,Put 可以在数据库中存储一行,或者在文件系统上存储文件等...)
因此,为 Product 类型实现 Istore 的类看起来有点像这样:
class MyStore : IStore<Product>
{
public Product Get(object identifier)
{
//whatever
}
public void Put(Product entity)
{
//Store the product in db
//RAISE EVENT ON SUCCESS
}
}
我所追求的是一种确保 IStore 的每个实现都会引发事件的方法 - 我应该有一个抽象类,还是接口?
【问题讨论】: