static void Main() { var serviceProvider = new ServiceCollection() .AddSingleton <IParser <string, long>, NumberParser>() .AddSingleton <IRulesEngine <long, string>, AmericanNumberFormatRulesEngine>() .AddSingleton <IRulesProcessor <long, string>, MultiThreadedRulesProcessor <long, string> >() .AddSingleton <IInputterDialogue <string>, ConsoleFileNameDialogue>() .AddSingleton <IInputter <string>, FileInputter>() .AddSingleton <IOutputter <string>, StdOutStringOutputter>() .BuildServiceProvider(); bool run = true; while (run) { try { IParser <string, long> parser = serviceProvider.GetService <IParser <string, long> >(); IList <long> numbersToConvert = parser.ParseInput(serviceProvider.GetService <IInputter <string> >().Get()); IRulesProcessor <long, string> rulesProcessor = serviceProvider.GetService <IRulesProcessor <long, string> >(); IList <string> wordsConverted = rulesProcessor.Process(numbersToConvert); IOutputter <string> outputter = serviceProvider.GetService <IOutputter <string> >(); outputter.Output(wordsConverted); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Run Again y/n?"); run = Console.ReadLine().ToLower() == "y" ? true : false; } }
public void Render(GameState gameState) { var screen = gameState.CurrentScreen; var newImage = new RenderedImage(gameState.LastImage); foreach (var viewport in screen.Viewports) { var offsetX = viewport.AtomToTrack.Position.X - viewport.Area.Width / 2; var offsetY = viewport.AtomToTrack.Position.Y - viewport.Area.Height / 2; for (int i = 0; i < viewport.Area.Height; i++) { var newLine = GenerateLine(viewport.Area.Width); for (int j = 0; j < viewport.Area.Width; j++) { ColouredChar?thisChar = null; foreach (var atom in gameState.CurrentLevel.GetAtoms(j + offsetX, i + offsetY)) { thisChar = atom.Tile; } if (thisChar != null) { newLine[j] = thisChar.Value; } } newImage.Inject(newLine, viewport.Area.X, viewport.Area.Y + i); } } var renderRect = new Rectangle(new Point(0, 0), gameState.WindowSize); foreach (var displayField in screen.DisplayFields) { var value = displayField.GetValue(); var lastX = Math.Min(displayField.X + value.Length, gameState.WindowSize.Width); if (renderRect.Intersect(displayField.X, displayField.Y)) { newImage.Inject(value.ToColouredCharArray(), displayField.X, displayField.Y); } } _outputter.Output(newImage, gameState.LastImage); gameState.LastImage = newImage; }
public void Log(GuruData dataToLog) { var row = String.Format("{0:HH:mm},{1},{2},{3},{4}\n", dataToLog.Timestamp, dataToLog.PitTemp, dataToLog.FoodTemp1, dataToLog.FoodTemp2, dataToLog.FoodTemp3); m_outputter.Output(row); }
private void Output(string str) { _output.Output(str); }