internal static ILineProcessor GetMockLineProcessor(IEnumerable <ILineSegment> lineSegments) { ILineProcessor lineProcessor = Substitute.For <ILineProcessor>(); lineProcessor.Segments.Returns(lineSegments); return(lineProcessor); }
public object LoadFromFile(ISimpleConfig config, string path) { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat(CultureInfo.InvariantCulture, "Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat(CultureInfo.InvariantCulture, "The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = LogManager.GetLogger("ScriptCs"); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new RoslynScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ConfigRScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return result.ReturnValue; }
public PersonBatchProcessor(IFileIORepository fileIORepository, IPersonRepository personRepository, ILineProcessor <Person> personLineProcessor, IPeopleReport[] reports) { _fileIORepository = fileIORepository; _personRepository = personRepository; _personLineProcessor = personLineProcessor; _reports = reports; }
public ScanningService(ILineProcessor lineProcessor, IDataAccess dataAccess, IFileReader fileReader) { _lineProcessor = lineProcessor; _dataAccess = dataAccess; _fileReader = fileReader; Mapper.CreateMap<WordItem, WordModel>(); }
public BaseEnemy(Vector2 position, int groupId) : base() { Size = new Vector2(2, 2); StartPosition = Position = position; this.groupId = groupId; lineProcessor = BaseResolver.Instance.Resolve <ILineProcessor>(); scriptProcessor = new ScriptProcessor(lineProcessor); }
private IFilePreProcessor GetFilePreProcessor() { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), new LoadLineProcessor(_fileSystem.Object) }; return(new FilePreProcessor(_fileSystem.Object, Mock.Of <ILog>(), lineProcessors)); }
private IFilePreProcessor GetFilePreProcessor(ILineProcessor customDirectiveProcessor, ILineProcessor loadLineProcessor) { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), loadLineProcessor, customDirectiveProcessor }; return(new FilePreProcessor(_fileSystem.Object, Mock.Of <ILog>(), lineProcessors)); }
private IFilePreProcessor GetFilePreProcessor() { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), new LoadLineProcessor(_fileSystem.Object), new ShebangLineProcessor() }; return(new FilePreProcessor(_fileSystem.Object, new TestLogProvider(), lineProcessors)); }
private IFilePreProcessor GetFilePreProcessor(ILineProcessor customDirectiveProcessor, ILineProcessor loadLineProcessor) { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), loadLineProcessor, new ShebangLineProcessor(), customDirectiveProcessor }; return(new FilePreProcessor(_fileSystem.Object, new TestLogProvider(), lineProcessors)); }
public object LoadFromFile(ISimpleConfig config, string path) { // HACK (adamralph): workaround for https://github.com/scriptcs/scriptcs/issues/1022 var originalCurrentDirectory = Environment.CurrentDirectory; try { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat("Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat("The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = new LogProviderAdapter(); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new CSharpScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); executor.AddReferences(this.references); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); // HACK (adamralph): BaseDirectory is set to bin subfolder in Initialize()! executor.ScriptEngine.BaseDirectory = executor.FileSystem.CurrentDirectory; try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return(result.ReturnValue); } finally { Environment.CurrentDirectory = originalCurrentDirectory; } }
public string SolveStep_Test(string lineData, IEnumerable <Point> points) { var groups = TestHelper.ParseGroups(lineData).ToArray(); var columnProcessors = new ILineProcessor[] { new ShiftProcessor(false), new FillProcessor(false), new AffiliationProcessor(false), new CompletionProcessor(), }; var cwLine = new CrossWordLine(groups, points.ToArray(), true, columnProcessors); cwLine.TrySolveStep(null); return(points.RenderToString()); }
////////////////////////////////////////////////////////////// /// <summary> /// This method is used to process the file. For each line, /// the ILineProcessor.ProcessLine method is called. /// </summary> /// <param name="lp">the line processor</param> /// <exception class="System.IO.IOException">if there is an /// error reading the file</exception> ////////////////////////////////////////////////////////////// public void ProcessFile(ILineProcessor lp) { StreamReader reader = null; if (!File.Exists(_filename)) { throw new FileNotFoundException(_filename); } try { if (_encoding != null) { reader = new StreamReader(_filename, Encoding.GetEncoding(_encoding)); } else { reader = new StreamReader(_filename); } lp.Reset(); string line = reader.ReadLine(); while (line != null) { lp.ProcessLine(line); line = reader.ReadLine(); } } finally { try { if (reader != null) { reader.Close(); } } catch (IOException) { // don't care } } }
public void Cannot_Resolve_Function_Factories_With_Duplicated_Types() { // arrange _container = _builder.Build(); ILineProcessor instance = null; // act var factory = _container.Resolve <Func <string, string, ILineProcessor> >(); try { instance = factory("A", "B"); } catch (DependencyResolutionException dre) { Debug.WriteLine(dre.Message); } // assert Assert.IsInstanceOfType(factory, typeof(Func <string, string, ILineProcessor>)); Assert.IsNull(instance); }
public object LoadFromFile(ISimpleConfig config, string path) { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat(CultureInfo.InvariantCulture, "Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat(CultureInfo.InvariantCulture, "The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = LogManager.GetLogger("ScriptCs"); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new RoslynScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ConfigRScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); executor.AddReferences(this.references); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return(result.ReturnValue); }
public void ProcessProperlyLines_Test() { // Arrange ArrangeMocks(); _lineProcessor = MockRepository.GenerateMock<ILineProcessor>(); var service = new ScanningService(_lineProcessor, _dataAccess, _fileReader); var actualLines = new List<string>(); _lineProcessor.Expect(x => x.Process(Arg<string>.Is.Anything)) .Repeat.Twice().WhenCalled(x => actualLines.Add((string)x.Arguments[0])) .Return(GetLineProcessorWorkResult()); // Act var actualResult = service.AddScanningFile(_testPath, _token); actualResult.Wait(_token); // Assert _lineProcessor.VerifyAllExpectations(); Assert.AreEqual(2, actualLines.Count); actualLines.ForEach(x => Assert.AreEqual(_testLine, x)); }
public object LoadFromFile(ISimpleConfig config, string path) { var fileSystem = new FileSystem { CurrentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase }; log.InfoFormat("Executing '{0}'", fileSystem.GetFullPath(path)); log.DebugFormat("The current directory is {0}", fileSystem.CurrentDirectory); var scriptCsLog = new LogProviderAdapter(); var lineProcessors = new ILineProcessor[] { new LoadLineProcessor(fileSystem), new ReferenceLineProcessor(fileSystem), new UsingLineProcessor(), }; var filePreProcessor = new FilePreProcessor(fileSystem, scriptCsLog, lineProcessors); var engine = new RoslynScriptInMemoryEngine(new ConfigRScriptHostFactory(config), scriptCsLog); var executor = new ScriptExecutor(fileSystem, filePreProcessor, engine, scriptCsLog); executor.AddReferenceAndImportNamespaces(new[] { typeof(Config), typeof(IScriptHost) }); executor.AddReferences(this.references); ScriptResult result; executor.Initialize(new string[0], new IScriptPack[0]); // HACK (adamralph): BaseDirectory is set to bin subfolder in Initialize()! executor.ScriptEngine.BaseDirectory = executor.FileSystem.CurrentDirectory; try { result = executor.Execute(path); } finally { executor.Terminate(); } RethrowExceptionIfAny(result, path); return result.ReturnValue; }
private IFilePreProcessor GetFilePreProcessor(ILineProcessor customDirectiveProcessor, ILineProcessor loadLineProcessor) { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), loadLineProcessor, new ShebangLineProcessor(), customDirectiveProcessor }; return new FilePreProcessor(_fileSystem.Object, new TestLogProvider(), lineProcessors); }
private IFilePreProcessor GetFilePreProcessor() { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), new LoadLineProcessor(_fileSystem.Object), new ShebangLineProcessor() }; return new FilePreProcessor(_fileSystem.Object, new TestLogProvider(), lineProcessors); }
public LineProcessorCollector(ILineProcessor next) { this.next = next; }
public void setNextLineProcessor(ILineProcessor next) { this.next = next; }
public LineVisiter(ILineProcessor processor) { _processor = processor; }
public TextPresenter() { coroutineAccessor = Configurations.GlobalConfiguration.CoroutineAccessor; lineProcessor = new LineProcessor <LineSegment>(); }
private IFilePreProcessor GetFilePreProcessor() { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), new LoadLineProcessor(_fileSystem.Object) }; return new FilePreProcessor(_fileSystem.Object, Mock.Of<ILog>(), lineProcessors); }
public void Initialize() { _lineProcessor = MockRepository.GenerateMock<ILineProcessor>(); _dataAccess = MockRepository.GenerateMock<IDataAccess>(); _fileReader = MockRepository.GenerateMock<IFileReader>(); }
public RelevantValue(ILineProcessor processInstructions, double value) { Value = value; Operation = processInstructions.OperationType; PeriodChoice = processInstructions.Period; }
public Builder(ILineProcessor lineProcessor) { LineProcessor = lineProcessor; }
public FileProcessor(ILineReader reader, ILineProcessor processor) { _reader = reader; _processor = processor; }
public ScriptProcessor(ILineProcessor lineProcessor) { this.lineProcessor = lineProcessor; this.targetObject = lineProcessor.TargetObject; }
public LineTeeProcessor(ILineProcessor tee) { this.tee = tee; }
public TextPresenter(ICoroutineAccessor coroutineAccessor, ILineProcessor lineProcessor) { this.coroutineAccessor = coroutineAccessor; this.lineProcessor = lineProcessor; }
public ByGenderPeopleReport(ILineProcessor <Person> lineProcessor) { _lineProcessor = lineProcessor; }
public FormatLinesFlow(LineProcessingConfiguration configuration) { _patcher = LineProcessorBuilder.Build(configuration); }
public ByLastNamePeopleReport(ILineProcessor <Person> lineProcessor) { _lineProcessor = lineProcessor; }
public void setNextLineProcessor(ILineProcessor next) { processor = next; }
public bool TryCreateLineProcessor(char key, out ILineProcessor lineProcessor) { lineProcessor = new DefaultLineProcessor(); return(true); }
private IFilePreProcessor GetFilePreProcessor(ILineProcessor customDirectiveProcessor, ILineProcessor loadLineProcessor) { var lineProcessors = new ILineProcessor[] { new UsingLineProcessor(), new ReferenceLineProcessor(_fileSystem.Object), loadLineProcessor, customDirectiveProcessor }; return new FilePreProcessor(_fileSystem.Object, Mock.Of<ILog>(), lineProcessors); }
public ByDateOfBirthPeopleReport(ILineProcessor <Person> lineProcessor) { _lineProcessor = lineProcessor; }