internal static void Run(IInstructionHandler handler, List<Cell> cells, Action<ExecutionContext> before, Action<ExecutionContext, string> after, SecureRandom randomizer) { using (var reader = new StringReader(string.Empty)) { InstructionHandlerTests.Run(handler, cells, before, after, randomizer, reader); } }
internal static void Run(IInstructionHandler handler, List<Cell> cells, Action<ExecutionContext> before, Action<ExecutionContext, string> after, TextReader reader) { using (var random = new SecureRandom()) { InstructionHandlerTests.Run(handler, cells, before, after, random, reader); } }
public Interpreter(FileInfo file, TextReader reader, TextWriter writer, SecureRandom randomizer) : base() { if (file == null) { throw new ArgumentNullException(nameof(file)); } this.executor = new Executor( new Parser(File.ReadAllLines(file.FullName)).Parse(), reader, writer, randomizer); }
internal ExecutionContext(List<Cell> cells, TextReader reader, TextWriter writer, SecureRandom randomizer) : base() { this.Cells = cells; this.CurrentPosition = new Point(); this.Direction = Direction.Right; this.InStringMode = false; this.Randomizer = randomizer; this.Values = new Stack<int>(); this.Reader = reader; this.Writer = writer; this.Next(); }
private static void Run(IInstructionHandler handler, List<Cell> cells, Action<ExecutionContext> before, Action<ExecutionContext, string> after, SecureRandom randomizer, TextReader reader) { using (var writer = new StringWriter(CultureInfo.CurrentCulture)) { using (reader) { var context = new ExecutionContext(cells, reader, writer, randomizer); before?.Invoke(context); handler.Handle(context); var result = writer.GetStringBuilder().ToString(); after?.Invoke(context, result); } } }
public Executor(ImmutableArray<Cell> cells, TextReader reader, TextWriter writer, SecureRandom randomizer) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (randomizer == null) { throw new ArgumentNullException(nameof(randomizer)); } this.cells = cells; this.reader = reader; this.writer = writer; this.randomizer = randomizer; }
public Interpreter(string[] lines, TextReader reader, TextWriter writer, SecureRandom randomizer) : base() { this.executor = new Executor( new Parser(lines).Parse(), reader, writer, randomizer); }