-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApproval.cs
25 lines (20 loc) · 879 Bytes
/
Approval.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
namespace chain.of.responsibility.pattern
{
public class Approval
{
public ApprovalResponse ApproveExpense(decimal expenseReportAmount)
{
ExpenseHandler william = new ExpenseHandler(new Employee("William Worker", decimal.Zero));
ExpenseHandler mary = new ExpenseHandler(new Employee("Mary Manager", 1000m));
ExpenseHandler victor = new ExpenseHandler(new Employee("Victor Vicepres", 5000m));
ExpenseHandler paula = new ExpenseHandler(new Employee("Paula President", 20000m));
william.RegisterNext(mary);
mary.RegisterNext(victor);
victor.RegisterNext(paula);
IExpenseReport expense = new ExpenseReport(expenseReportAmount);
ApprovalResponse response = william.Approve(expense);
return response;
}
}
}