public static void Main(string[] args) { ICommandPool commandPool = new CommandPool(); commandPool.Register <PrintHello, PrintHelloCommand>(); commandPool.Register <Summarize, SummarizeCommand>(); commandPool.Register <PrintText, PrintTextCommand>(); PerformerFactory factory = PerformerFactory.Instance; IPerformer performer = factory.Create(commandPool); performer.Invoke(new PrintHello()); performer.Invoke(new Summarize()); performer.Invoke(new PrintText("Print this text, pls! c:")); }
public int AddCommand(Command cmd) { commandPool.Register(cmd); m_allCommands.Add(cmd); selectIndex = TotalCommandCount; return(selectIndex); }
private void BindingCommands() { var storageManager = new StorageManager(); ICommandPool commandPool = new CommandPool(); var performerFactory = new PerformerFactory(); _performer = performerFactory.Create(commandPool); commandPool.Register <LoadGame>(new LoadGameCommand(storageManager, _cellControllers.Values.ToList(), _shovelController, _goldWalletController, _goldBarsSpawnerController, _gameProcessController)); commandPool.Register <Dig>(new DigCommand(_performer, _shovelController, storageManager)); commandPool.Register <SpawnGoldBar>(new SpawnGoldBarCommand(_goldBarsSpawnerController, storageManager)); commandPool.Register <CollectGold>(new CollectGoldCommand(_goldWalletController, _goldBarsSpawnerController, storageManager)); commandPool.Register <EndGame>(new EndGameCommand(_gameProcessController, storageManager)); commandPool.Register <RestartGame>(new RestartGameCommand(_shovelController, _goldWalletController, _cellControllers, _goldBarsSpawnerController, _gameProcessController, storageManager)); }