Exemplo n.º 1
0
        public override bool ParseNext()
        {
            string currentLine;

            while ((currentLine = _extendedStreamReader.ReadLineWithEofLine()) != null)
            {
                ProgressInPercent = (byte)(_extendedStreamReader.CurrentLineNumber * 100 / _totalNumberOfLines);

                var parseResult = _lineParsingSession.Parse(currentLine);

                _entryBuilder.Add(parseResult, _extendedStreamReader.CurrentLineNumber);

                if (_entryBuilder.CompleteEntry == null || string.IsNullOrEmpty(_entryBuilder.CompleteEntry.MessageId))
                {
                    continue;
                }

                var paragraphUnit = _paragraphUnitFactory.Create(
                    _entryBuilder.CompleteEntry,
                    _segmentSettings.SourceLineType,
                    _segmentSettings.IsTargetTextNeeded);

                Output.ProcessParagraphUnit(paragraphUnit);

                return(parseResult.LineType != LineType.EndOfFile);
            }

            return(false);
        }
Exemplo n.º 2
0
        private void MathParseResultWithEntry(string line, IParseResult parseResult, Entry completeEntry)
        {
            if (string.IsNullOrEmpty(line))
            {
                A.CallTo(() => _lineParsingSessionMock.Parse(A <string> .Ignored)).Returns(parseResult);
            }
            else
            {
                A.CallTo(() => _lineParsingSessionMock.Parse(line)).Returns(parseResult);
            }

            A.CallTo(() => _entryBuilderMock.Add(parseResult, A <int> .Ignored))
            .Invokes(() => { A.CallTo(() => _entryBuilderMock.CompleteEntry).Returns(completeEntry); });
        }
Exemplo n.º 3
0
        public void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
        {
            var contextInfo        = paragraphUnit.Properties.Contexts.Contexts[1];
            var messageStringStart = int.Parse(contextInfo.GetMetaData(ContextKeys.MetaMessageStringStart));
            var messageStringEnd   = int.Parse(contextInfo.GetMetaData(ContextKeys.MetaMessageStringEnd));

            string currentOriginalLine;

            while ((currentOriginalLine = _extendedStreamReader.ReadLineWithEofLine()) != null)
            {
                if (_extendedStreamReader.CurrentLineNumber < messageStringStart)
                {
                    _streamWriter.WriteLine(currentOriginalLine);
                }

                var parseResult = _lineParsingSession.Parse(currentOriginalLine);

                _entryBuilder.Add(parseResult, _extendedStreamReader.CurrentLineNumber);

                var completeEntry = _entryBuilder.CompleteEntry;

                if (completeEntry == null || string.IsNullOrEmpty(completeEntry.MessageId))
                {
                    continue;
                }

                WriteMessageString(paragraphUnit, completeEntry.IsPluralForm);

                if (_extendedStreamReader.CurrentLineNumber > messageStringEnd && parseResult.LineType != LineType.EndOfFile)
                {
                    _streamWriter.WriteLine(currentOriginalLine);
                }

                break;
            }
        }