コード例 #1
0
        public ReadResult Read(Chunk chunk)
        {
            var result = new ReadResult();

            var match = Regex.Match(chunk.Text, Paths_Regex);

            if(match.Success)
            {
                // remove extra line feeds
                var newLines = match.Groups[1].Value.Length > 0 ? "\n" : string.Empty;
                var replaced =
                    chunk.Text.Replace(
                        match.Groups[0].Value,
                        "{0}Obvious {1}: {2}.".ToFormat(
                            newLines,
                            match.Groups[2].Value,
                            match.Groups[3].Value));

                result.Chunk = Chunk.For(replaced);
            }
            else
            {
                result.Chunk = chunk;
            }

            return result;
        }
コード例 #2
0
ファイル: NewGameParser.cs プロジェクト: joemcbride/outlander
        public ReadResult Parse(Chunk chunk)
        {
            var overallResult = new ReadResult();

            System.Diagnostics.Debug.WriteLine("Parsing: " + chunk.Text);

            if(_lastIdx > -1)
            {
                var parser = _parsers[_lastIdx];
                var result = parser.Read(chunk);
                chunk = result.Chunk;
                overallResult.AddTags(result.Tags);
                if (result.Stop) {
                    if(chunk != null && !string.IsNullOrWhiteSpace(chunk.Text))
                    {
                        overallResult.Chunk = chunk;
                    }
                    return overallResult;
                }

                _lastIdx = -1;
            }

            for (var i = 0; i < _parsers.Count; i++) {
                if (chunk == null)
                    break;

                var parser = _parsers[i];

                var result = parser.Read(chunk);
                chunk = result.Chunk;
                overallResult.AddTags(result.Tags);

                if (result.Stop) {
                    _lastIdx = i;
                }
            }

            if(chunk != null && !string.IsNullOrWhiteSpace(chunk.Text))
            {
                overallResult.Chunk = chunk;
            }

            var tags = Transform(overallResult.Tags);
            overallResult.ClearTags();
            overallResult.AddTags(tags);

            return overallResult;
        }
コード例 #3
0
        public ReadResult Read(Chunk chunk)
        {
            var result = new ReadResult();

            if(chunk.Text != null && Regex.IsMatch(chunk.Text, Paths_Regex))
            {
                var replaced = Regex.Replace(chunk.Text, Paths_Regex, "</preset>  \nYou also see");

                result.Chunk = Chunk.For(replaced);
            }
            else
            {
                result.Chunk = chunk;
            }

            return result;
        }
コード例 #4
0
 public ReadResult Read(Chunk chunk)
 {
     return _reader.Read(chunk);
 }
コード例 #5
0
 public ReadResult Read(Chunk chunk)
 {
     var result = _reader.Read(chunk);
     _count = 0;
     return result;
 }