Skip to content

Commit c05ca8f

Browse files
author
Joseph Phillips
committed
Updated README.
1 parent 25dfa74 commit c05ca8f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Enflow
22
======
33

4-
Enflow is a simple library for workflows and business rules. It is an ideal replacement for the _Unit of Work_ pattern popular in MVC applications, particularly where model state validation must accompany units of work.
4+
Enflow is a simple library for workflows and state/business rules. It is an ideal replacement for the _Unit of Work_ pattern popular in MVC applications, particularly where model state validation must accompany units of work.
55

66
Usage is not limited to MVC. Enflow is a [Portable Class Library](http://msdn.microsoft.com/en-us/library/gg597391.aspx) (PCL) and works across multiple platforms. For more information, including usage in _Mono for Android_ and _MonoTouch_, have a read of [this blog post](http://slodge.blogspot.sk/2012/12/cross-platform-winrt-monodroid.html) by Stuart Lodge ([@slodge](https://twitter.com/slodge)).
77

@@ -17,19 +17,21 @@ public class Employee : IModel<Employee>
1717
}
1818
```
1919

20-
### Business Rules
20+
### State Rules
2121

22-
Create business rules based on your models and use the fluent API to create composite rules from atomic constituents.
22+
Create rules based on your models and use the fluent API to create composite rules from atomic constituents.
2323
```csharp
24-
public class MaxSalaryRule : BusinessRule<Employee>
24+
public class MaxSalaryRule :
25+
StateRule<Employee>
2526
{
2627
public override bool IsSatisfied(Employee candidate)
2728
{
2829
return candidate.Salary < 40000;
2930
}
3031
}
3132

32-
public class InHrDepartmentRule : BusinessRule<Employee>
33+
public class InHrDepartmentRule :
34+
StateRule<Employee>
3335
{
3436
public override bool IsSatisfied(Employee candidate)
3537
{
@@ -45,14 +47,15 @@ var salaryRaiseRule = new MaxSalaryRule()
4547

4648
### Workflows
4749

48-
This is our new _Unit of Work_. Instantiate, passing in the rule to be validated. If the rule validation fails, a _BusinessRuleException_ will be thrown with the rule description as the message.
50+
This is our new _Unit of Work_. Instantiate, passing in the rule to be validated. If the rule validation fails, a _StateRuleException_ will be thrown with the rule description as the message.
4951
```csharp
5052
// Example incorporating a repository pattern.
5153
public class ApplySalaryRaise : Workflow<Employee>
5254
{
5355
private readonly IRepository<Employee> _repository;
5456

55-
public ApplySalaryRaise(IBusinessRule<Employee> rule, IRepository<Employee> repository)
57+
public ApplySalaryRaise(I
58+
StateRule<Employee> rule, IRepository<Employee> repository)
5659
: base(rule)
5760
{
5861
_repository = repository;
@@ -86,7 +89,7 @@ var salaryRaiseWorflow = new ApplySalaryRaise(salaryRaiseRule, new EmployeeRepos
8689
// Will be granted the salary raise.
8790
salaryRaiseWorflow.Execute(eligibleEmployee);
8891

89-
// Will throw a BusinessRuleException.
92+
// Will throw a StateRuleException.
9093
salaryRaiseWorflow.Execute(ineligibleEmployee);
9194

9295
// It is also possible to chain multiple workflows using the fluent API.
@@ -182,11 +185,11 @@ public class MvcApplication : System.Web.HttpApplication
182185
builder.Register(c => new MaxSalaryRule()
183186
.And(new InHrDepartmentRule())
184187
.Describe("Employee must be in the HR deparment and have a salary less than $40,000."))
185-
.Named<IBusinessRule<Employee>>(salaryAndDeptRule)
188+
.Named<IStateRule<Employee>>(salaryAndDeptRule)
186189
.InstancePerHttpRequest();
187190

188191
builder.Register(c => new ApplySalaryRaise(
189-
c.ResolveNamed<IBusinessRule<Employee>>(salaryAndDeptRule),
192+
c.ResolveNamed<IStateRule<Employee>>(salaryAndDeptRule),
190193
c.Resolve<IRepository<Employee>>()))
191194
.Named<IWorkflow<Employee>>(Workflows.SalaryRaise)
192195
.InstancePerHttpRequest();

0 commit comments

Comments
 (0)