【发布时间】:2010-12-04 11:55:51
【问题描述】:
我想做这样的事情
public class ProductBiz: BizBase<Product> {
public List<String> BrokenRules {get;set;}
// Some kind of data + biz operation implementation
}
public static class ProductBizExtensions{
public ProductBiz Rule1(this ProductBiz prodBiz)
{}
public ProductBiz Rule2(this ProductBiz prodBiz)
{}
public bool ApplyRules (this ProductBiz prodBiz, Func<ProductBiz,bool> ruleset){}
}
然后在客户端代码中使用它
productBiz.Rule1().Rule2();
productBiz.Rule2().Rule1();
或
// create multicasted delegate of type Func<ProductBiz,bool> say rulesetDelegate
productBiz.ApplyRules(rulesetDelegate);
只是想在我深潜淹死之前问一下。
这种方法的潜在缺陷是什么???
提前致谢
【问题讨论】:
-
您的第一个代码块中是否有错字?第二个
Rule1应该是Rule2吗?
标签: c# business-objects rule-engine business-logic-layer business-rules