public void Compile(IRuleDefinitionContext context) { foreach (var rule in _rules) { rule.Compile(context); } }
public override void Define(IRuleDefinitionContext ruleContext) { //var newOrders = ruleContext.OnNew<Order>(); //var updatedOrders = ruleContext.OnChange<Order>().Select(orderFact => (orderFact.Context, orderFact.Fact)); _disposable = ruleContext.OnNew <Order>() .Where(orderFact => orderFact.Fact.IsOpen) .Where(orderFact => !orderFact.Fact.IsDiscounted) .Subscribe(orderFact => { var context = orderFact.Context; var order = orderFact.Fact; var customer = context.Get <Customer>(order.Customer.Id); if (customer.IsPreferred) { order.ApplyDiscount(10.0); context.Update(order, nameof(Order.PercentDiscount)); } }); }
public abstract void Define(IRuleDefinitionContext context);
public void Compile(IRuleDefinitionContext context) { Define(context); }