-
Notifications
You must be signed in to change notification settings - Fork 7
Constraining Rules
Arif Yayalar (@ayayalar) edited this page Dec 30, 2019
·
3 revisions
Constraint
option checks whether the rule should be invoked or not.
Must be set in the Initialize , or the InitializeAsync method. |
class QualifiesForFreeShipping : Rule<Order>
{
// If the order amount is greater than $50, then the Invoke method is called.
public override void Initialize() =>
Configuration.Constraint = order => order.Total > 50m;
public override IRuleResult Invoke() => Model.FreeShipping = true;
}
class Order
{
public int Id { get; set; }
public decimal Total { get; set; }
public bool FreeShipping { get; set; }
}
Synchronous Rules |
Asynchronous Rules |
Parallel Rules |
Reactive Rules |
Proactive Rules |
ExceptionHandler Rules |