public TransferMoneyContext(TransferMoneySource source, TransferMoneySink sink, double amount) { Source = source; Sink = sink; Amount = amount; }
public static void TransferTo(this TransferMoneySource self, TransferMoneySink recipient, double amount) { if (self.Balance < amount) { throw new ApplicationException("insufficient funds"); } self.Withdraw(amount); self.Log("Withdrawing " + amount); recipient.Deposit(amount); recipient.Log("Depositing " + amount); }
// the interface is used here as a jumpboard for kicking off the extension method (it works as a methodful role) instead of the traditional use of interfaces public static void TransferTo(this TransferMoneySource self, TransferMoneySink recipient, double amount) { // The implementation of the use case by using the "primitive methods" of the domain objects if (self.Balance < amount) { throw new ApplicationException("insufficient funds"); } self.Withdraw(amount); self.Log("Withdrawing " + amount); recipient.Deposit(amount); recipient.Log("Depositing " + amount); }
public static void TransferTo(this TransferMoneySource self, TransferMoneySink recipient, decimal amount) { // The implementation of the use case if (self.Balance < amount) { throw new ApplicationException( "insufficient funds"); } self.Withdraw(amount); self.Log("Withdrawing " + amount); recipient.Deposit(amount); recipient.Log("Depositing " + amount); }
public static void TransferTo(this TransferMoneySource self, TransferMoneySink recipient, double amount) { if (self != null && recipient != null) { if (self.Balance < amount) { self.Log("Insufficient funds"); } else { self.Withdraw(amount); self.Log("Withdrawing " + amount); recipient.Deposit(amount); recipient.Log("Depositing " + amount); } } }
public void To(TransferMoneySink sink) { this.sink = sink; DoIt(); }
public TransferMoneyContext(TransferMoneySource source, TransferMoneySink sink, decimal amount) { Source = source; Sink = sink; Amount = amount; }