static void Main(String[] args) { // With dependency injection. //var operationHandler = DependencyServiceProvider.Get().GetService<IOperationHandler>(); var operationHandler = new OperationHandler(new BuySellOperationHandler()); while (true) { var argument = Console.ReadLine(); if (string.IsNullOrEmpty(argument)) { break; } if (argument.ToUpper() == OperationType.Print) { operationHandler.Print(); } else { var operation = OperationsFactory.Get(argument); operationHandler.Process(operation); } } }