示例#1
0
        private static int ParseSlotRegion(this RcTemplate template, SubArray <string> textLines)
        {
            //Find the lines that belong to this region
            textLines = template.FindSlotRegionLines(textLines);

            var beginLineText = textLines.FirstItem;

            var m = template.RegionBeginMarker.MarkerRegex.Match(beginLineText);

            var regionLinePrefix =
                m.Index > 0
                ? beginLineText.Substring(0, m.Index)
                : string.Empty;

            var tagString =
                m.Index + m.Length < beginLineText.Length
                ? beginLineText.Substring(m.Index + m.Length)
                : string.Empty;

            var slotRegion = template.AddSlotRegion(tagString, regionLinePrefix);

            var subArray =
                (template.RegionEndMarker.MarkerRegex.IsMatch(textLines.LastItem))
                    ? textLines.GetSubArray(1, textLines.LastIndex - 1)
                    : textLines.GetSubArray(1, textLines.LastIndex);

            slotRegion.ParseTags(subArray);

            //Return the number of lines used in this region
            return(textLines.Length);
        }
示例#2
0
        private static SubArray <string> FindJoinSlotTagsLines(this RcSlotRegion region, SubArray <string> textLines)
        {
            var generatedTextFound = false;

            for (var i = 1; i <= textLines.LastIndex; i++)
            {
                var textLine = textLines[i];

                if (region.JoinSlotTagsEndMarker.MarkerRegex.IsMatch(textLine))
                {
                    //Make sure to take all generated text after the end join tags marker is found
                    for (var j = i + 1; j <= textLines.LastIndex; j++)
                    {
                        textLine = textLines[j];

                        if (region.JoinSlotTagsBeginMarker.MarkerRegex.IsMatch(textLine) ||
                            region.SlotTagMarker.MarkerRegex.IsMatch(textLine) ||
                            region.FixedTagMarker.MarkerRegex.IsMatch(textLine)
                            )
                        {
                            return(textLines.GetSubArray(0, j - 1));
                        }
                    }

                    return(textLines);
                }

                if (region.JoinSlotTagsBeginMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i - 1));
                }

                if (region.FixedTagMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i - 1));
                }

                if (region.SlotTagMarker.MarkerRegex.IsMatch(textLine))
                {
                    if (generatedTextFound)
                    {
                        return(textLines.GetSubArray(0, i - 1));
                    }
                }
                else
                {
                    generatedTextFound = true;
                }
            }

            return(textLines);
        }
示例#3
0
        private static void ParseTags(this RcSlotRegion region, SubArray <string> textLines)
        {
            var lineIndex = 0;

            while (lineIndex <= textLines.LastIndex)
            {
                var textLine = textLines[lineIndex];

                var subArray = textLines.GetSubArray(lineIndex, textLines.LastIndex);

                if (region.JoinSlotTagsBeginMarker.MarkerRegex.IsMatch(textLine))
                {
                    lineIndex += region.ParseJoinSlotTags(subArray);
                }

                else if (region.SlotTagMarker.MarkerRegex.IsMatch(textLine))
                {
                    lineIndex += region.ParseSlotTag(subArray);
                }

                else
                {
                    lineIndex += region.ParseFixedTag(subArray);
                }
            }
        }
示例#4
0
        private static SubArray <string> FindSlotRegionLines(this RcTemplate template, SubArray <string> textLines)
        {
            for (var i = 1; i <= textLines.LastIndex; i++)
            {
                var textLine = textLines[i];

                if (template.RegionEndMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i));
                }

                if (template.RegionBeginMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i - 1));
                }
            }

            return(textLines);
        }
示例#5
0
        private static SubArray <string> FindFixedTagLines(this RcSlotRegion region, SubArray <string> textLines)
        {
            for (var i = 1; i <= textLines.LastIndex; i++)
            {
                var textLine = textLines[i];

                if (region.SlotTagMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i - 1));
                }

                if (region.JoinSlotTagsBeginMarker.MarkerRegex.IsMatch(textLine))
                {
                    return(textLines.GetSubArray(0, i - 1));
                }
            }

            return(textLines);
        }
示例#6
0
        private static void ParseRegions(this RcTemplate template, SubArray <string> textLines)
        {
            var lineIndex = 0;

            while (lineIndex < textLines.Length)
            {
                var textLine = textLines[lineIndex];

                var subArray = textLines.GetSubArray(lineIndex, textLines.Length - 1);

                if (template.RegionBeginMarker.MarkerRegex.IsMatch(textLine))
                {
                    lineIndex += template.ParseSlotRegion(subArray);
                }

                else
                {
                    lineIndex += template.ParseFixedRegion(subArray);
                }
            }
        }