Created
January 26, 2017 14:11
-
-
Save pauldambra/4b7de7edca00da42b0e4cf18b784c362 to your computer and use it in GitHub Desktop.
Application Services as Open Closed...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Command {} | |
public class GetStockCommand("name", 10M) : Command { | |
//set properties | |
DateAdded = DateTime.now; | |
} | |
public interface IHandle<Command, TResult> | |
{ | |
TResult Handle(Command command); | |
} | |
public class GetStockHandler : IHandle<GetStockCommand, StockItem> | |
{ | |
public StockItem Handle(GetStockCommand cmd) { | |
//load from hipster database | |
} | |
} | |
public class PriceReducingGetStockHandler : IHandle<GetStockCommand, StockItem> | |
{ | |
public PriceReducingGetStockHandler(GetStockHandler baseHandler) | |
{_baseHandler = baseHandler;} | |
public StockItem Handle(GetStockCommand cmd) { | |
var si = _baseHandler.Handle(cmd); | |
si = si.ReducePriceFor(DateTime.Now); | |
return si; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment