// A new composed class wrapping each approver private IApprover WrapApprover(IApprover approver) { ApprovalAccount approvalAccount = new ApprovalAccount(approver.GetType().Name); addAccountAction(approvalAccount); IApprover postApprover = beethovenFactory.Generate <IApprover>( LinkedMethodsReturnValue.Create <IApprover>(nameof(IApprover.Approve)) .PartialMatchMethod(approvalAccount) .PartialMatchMethod(companyAccount) ); Action <double, string, bool> currentResultAction = approveAction; currentResultAction += (amount, approvedBy, accepted) => { if (accepted) { postApprover.NotifyApprove(amount); } }; return(beethovenFactory.Generate <IApprover>( LinkedMethodsReturnValue.Create <IApprover>(nameof(IApprover.Approve)) .AutoMappedMethod(approver) .InvertResult() .SkipIfResultCondition <bool>(value => value) .PartialMatchMethod(new MailApprover(approver, mailService, currentResultAction)) )); }
public Factory(MailService mailService, Action <double, string, bool> approveAction, ApprovalAccount companyAccount, Action <ApprovalAccount> addAccountAction) { this.mailService = mailService; this.approveAction = approveAction; this.companyAccount = companyAccount; this.addAccountAction = addAccountAction; }