我期待在客戶端代碼中做這樣的事情我們可以使用擴展方法來構建業務規則引擎嗎?
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();
OR
// create multicasted delegate of type Func<ProductBiz,bool> say rulesetDelegate
productBiz.ApplyRules(rulesetDelegate);
只想問之前,我潛入深海淹死。
什麼是這種方法潛在的缺陷???
在此先感謝
有沒有在你的第一個代碼塊一個錯字?第二個Rule1實際上應該是Rule2嗎? – MusiGenesis 2009-10-07 03:09:22
thanks..corrected – Perpetualcoder 2009-10-07 03:17:54