コード例 #1
0
        public ApprovalResponse Approve(IExpenseReport expenseReport)
        {
            var response = _approver.ApproveExpense(expenseReport);


            return(response == ApprovalResponse.Denied ? _next.Approve(expenseReport) : response);
        }
コード例 #2
0
        public ApprovalResponse Approve(IExpenseReport expenseReport)
        {
            var response = _expenseApprover.ApproveExpense(expenseReport);

            return(response == ApprovalResponse.BeyondApprovalLimit
                                ? _expenseHandler.Approve(expenseReport)
                                : response);
        }
コード例 #3
0
ファイル: Example.cs プロジェクト: aNizov/DesignPatterns
        public ApprovalResponse Approve(IExpenseReport expenseReport)
        {
            ApprovalResponse response = _approver.ApproveExpense(expenseReport);

            return(response == ApprovalResponse.BeyondApprovalLimit
                ? _next.Approve(expenseReport)
                : response);
        }
コード例 #4
0
        public ApprovalResponse Approve(IExpenseReport expense)
        {
            ApprovalResponse response = _approver.ApproveExpense(expense);

            if (response == ApprovalResponse.BeyondApprovalLimit)
            {
                return(_next.Approve(expense));
            }
            return(response);
        }
コード例 #5
0
        public ApprovalResponse Approve(Expense expense)
        {
            var response = _approver.ApproveExpense(expense);

            if (response == ApprovalResponse.BeyondApprovalLimit)
            {
                return(_next.Approve(expense));
            }

            return(response);
        }
コード例 #6
0
        public ApprovalResponse Approve(IExpenseReport expenseReport)
        {
            ApprovalResponse response = _approver.ApproveExpense(expenseReport);

            if (response == ApprovalResponse.BeyondApprovalLimit)
            {
                return(_next.Approve(expenseReport));
            }
            Console.WriteLine($"Approved by {(_approver as Employee).Name}");
            return(response);
        }
コード例 #7
0
        //################################################################################
        #region IExpenseHandler Implementation

        ApprovalResponse IExpenseHandler.Approve(IExpenseReport expenseReport, out string approverName)
        {
            approverName = m_Approver.Name;
            var response = m_Approver.ApproveExpense(expenseReport);

            if (response == ApprovalResponse.BeyondApprovalLimit)
            {
                return(m_NextHandler.Approve(expenseReport, out approverName));
            }

            return(response);
        }
コード例 #8
0
        public ApprovalResponse HandleExpense(IExpenseReport expenseReport)
        {
            var response = _expenseApprover.ApproveExpense(expenseReport);

            if (response != ApprovalResponse.BeyondApprovalLimit)
            {
                Console.WriteLine($"The request was {response} by {_expenseApprover.Name}");
            }
            else
            {
                if (_successor == null)
                {
                    Console.WriteLine("No one was able to approve your expense.");
                }
                else
                {
                    _successor.HandleExpense(expenseReport);
                }
            }

            return(response);
        }