Пример #1
0
        private void CompilerFor(BlockToken item, StringBuilder builder)
        {
            var start  = 0;
            var length = Matches.Count;

            if (!string.IsNullOrWhiteSpace(item.Content))
            {
                var args = item.Content.Split(',');
                if (args.Length < 2)
                {
                    length = Math.Min(Convert.ToInt32(args[0]), Matches.Count);
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(args[0]))
                    {
                        start = Math.Max(0, Convert.ToInt32(args[0]));
                    }
                    if (!string.IsNullOrWhiteSpace(args[1]))
                    {
                        length = Math.Min(Convert.ToInt32(args[1]), Matches.Count);
                    }
                }
            }
            for (; start < length; start++)
            {
                FormatBlockInner(item.Children, Matches[start], start, string.Empty, builder);
            }
        }
Пример #2
0
        private void CompilerStringFor(BlockToken item, StringBuilder builder)
        {
            var content = SplitFunc(item.Content, out var defFunc);
            var args    = content.Split(',');

            for (int i = 0; i < args.Length; i++)
            {
                FormatBlockInner(item.Children, args[i], i, defFunc, builder);
            }
        }
Пример #3
0
        private void CompilerIntFor(BlockToken item, StringBuilder builder)
        {
            var content = SplitFunc(item.Content, out var defFunc);
            var mathes  = Regex.Matches(content, @"\d+");
            var start   = 0;

            if (mathes.Count > 1)
            {
                start = Convert.ToInt32(mathes[0].Value);
            }
            var length = Convert.ToInt32(mathes[mathes.Count - 1].Value);
            var offset = mathes.Count > 2 ? Convert.ToInt32(mathes[1].Value) - start : 1;
            var i      = -1;

            for (; start <= length; start += offset)
            {
                i++;
                FormatBlockInner(item.Children, start, i, defFunc, builder);
            }
        }