Exemplo n.º 1
0
        internal static ILineProcessor GetMockLineProcessor(IEnumerable <ILineSegment> lineSegments)
        {
            ILineProcessor lineProcessor = Substitute.For <ILineProcessor>();

            lineProcessor.Segments.Returns(lineSegments);
            return(lineProcessor);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public PersonBatchProcessor(IFileIORepository fileIORepository, IPersonRepository personRepository, ILineProcessor <Person> personLineProcessor, IPeopleReport[] reports)
        {
            _fileIORepository = fileIORepository;

            _personRepository    = personRepository;
            _personLineProcessor = personLineProcessor;
            _reports             = reports;
        }
Exemplo n.º 4
0
        public ScanningService(ILineProcessor lineProcessor, IDataAccess dataAccess, IFileReader fileReader)
        {
            _lineProcessor = lineProcessor;
            _dataAccess = dataAccess;
            _fileReader = fileReader;

            Mapper.CreateMap<WordItem, WordModel>();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
            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));
            }
Exemplo n.º 7
0
            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));
            }
Exemplo n.º 8
0
            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));
            }
Exemplo n.º 9
0
            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));
            }
Exemplo n.º 10
0
        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;
            }
        }
Exemplo n.º 11
0
        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());
        }
Exemplo n.º 12
0
        //////////////////////////////////////////////////////////////
        /// <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
                }
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
            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);
            }
Exemplo n.º 18
0
            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);
            }
Exemplo n.º 19
0
 public LineProcessorCollector(ILineProcessor next)
 {
     this.next = next;
 }
Exemplo n.º 20
0
 public void setNextLineProcessor(ILineProcessor next)
 {
     this.next = next;
 }
Exemplo n.º 21
0
 public LineVisiter(ILineProcessor processor)
 {
     _processor = processor;
 }
Exemplo n.º 22
0
 public TextPresenter()
 {
     coroutineAccessor = Configurations.GlobalConfiguration.CoroutineAccessor;
     lineProcessor     = new LineProcessor <LineSegment>();
 }
Exemplo n.º 23
0
            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);
            }
Exemplo n.º 24
0
 public void Initialize()
 {
     _lineProcessor = MockRepository.GenerateMock<ILineProcessor>();
     _dataAccess = MockRepository.GenerateMock<IDataAccess>();
     _fileReader = MockRepository.GenerateMock<IFileReader>();
 }
Exemplo n.º 25
0
 public RelevantValue(ILineProcessor processInstructions, double value)
 {
     Value        = value;
     Operation    = processInstructions.OperationType;
     PeriodChoice = processInstructions.Period;
 }
Exemplo n.º 26
0
 public Builder(ILineProcessor lineProcessor)
 {
     LineProcessor = lineProcessor;
 }
Exemplo n.º 27
0
 public FileProcessor(ILineReader reader, ILineProcessor processor)
 {
     _reader    = reader;
     _processor = processor;
 }
 public ScriptProcessor(ILineProcessor lineProcessor)
 {
     this.lineProcessor = lineProcessor;
     this.targetObject  = lineProcessor.TargetObject;
 }
Exemplo n.º 29
0
 public LineTeeProcessor(ILineProcessor tee)
 {
     this.tee = tee;
 }
Exemplo n.º 30
0
 public TextPresenter(ICoroutineAccessor coroutineAccessor, ILineProcessor lineProcessor)
 {
     this.coroutineAccessor = coroutineAccessor;
     this.lineProcessor     = lineProcessor;
 }
Exemplo n.º 31
0
 public ByGenderPeopleReport(ILineProcessor <Person> lineProcessor)
 {
     _lineProcessor = lineProcessor;
 }
Exemplo n.º 32
0
 public FormatLinesFlow(LineProcessingConfiguration configuration)
 {
     _patcher = LineProcessorBuilder.Build(configuration);
 }
Exemplo n.º 33
0
 public ByLastNamePeopleReport(ILineProcessor <Person> lineProcessor)
 {
     _lineProcessor = lineProcessor;
 }
Exemplo n.º 34
0
 public void setNextLineProcessor(ILineProcessor next)
 {
     processor = next;
 }
Exemplo n.º 35
0
 public bool TryCreateLineProcessor(char key, out ILineProcessor lineProcessor)
 {
     lineProcessor = new DefaultLineProcessor();
     return(true);
 }
Exemplo n.º 36
0
            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);
            }
Exemplo n.º 37
0
 public ByDateOfBirthPeopleReport(ILineProcessor <Person> lineProcessor)
 {
     _lineProcessor = lineProcessor;
 }