Esempio n. 1
0
        public string GetText(SplitItem item)
        {
            StringBuilder sb = StringBuilderCache.GetInstance();

            sb.Append((item.IsGroup) ? Captions.ShortGroup : Captions.ShortSplit);
            sb.Append(PrefixSeparator);

            if (item.IsGroup)
            {
                sb.Append(item.Name);
            }
            else
            {
                sb.Append(item.Number);
            }

            sb.Append(' ', SplitWidth - item.Name.Length);
            sb.Append(" ");

            sb.Append(Captions.ShortIndex);
            sb.Append(PrefixSeparator);

            sb.Append(' ', IndexWidth - item.Index.GetDigitCount());
            sb.Append(item.Index);
            sb.Append(" ");

            sb.Append(Captions.ShortLength);
            sb.Append(PrefixSeparator);

            sb.Append(' ', LengthWidth - item.Length.GetDigitCount());
            sb.Append(item.Length);
            sb.Append(" ");

            return(StringBuilderCache.GetStringAndFree(sb));
        }
Esempio n. 2
0
        public string GetText(
            int index,
            int length,
            int matchNumber,
            string?groupName,
            int captureNumber,
            bool omitMatchInfo = false,
            bool omitGroupInfo = false)
        {
            StringBuilder sb = StringBuilderCache.GetInstance();

            if (omitMatchInfo)
            {
                sb.Append(MatchSpaces);
            }
            else
            {
                AppendNumber(Captions.ShortMatch, matchNumber, MatchWidth);
            }

            if (groupName != null)
            {
                if (omitGroupInfo)
                {
                    sb.Append(GroupSpaces);
                }
                else
                {
                    Append(Captions.ShortGroup, groupName, GroupWidth);
                }
            }

            if (captureNumber != -1 &&
                CaptureWidth > 0)
            {
                AppendNumber(Captions.ShortCapture, captureNumber, CaptureWidth);
            }

            AppendNumber(Captions.ShortIndex, index, IndexWidth);
            AppendNumber(Captions.ShortLength, length, LengthWidth);

            return(StringBuilderCache.GetStringAndFree(sb));

            void Append(string caption, string value, int width)
            {
                if (caption.Length > 0)
                {
                    sb.Append(caption);
                    sb.Append(PrefixSeparator);
                }

                sb.Append(value);
                sb.Append(' ', width - value.Length);
                sb.Append(ItemSeparator);
            }

            void AppendNumber(string caption, int number, int width)
            {
                if (caption.Length > 0)
                {
                    sb.Append(caption);
                    sb.Append(PrefixSeparator);
                }

                sb.Append(' ', width - number.GetDigitCount());
                sb.Append(number);
                sb.Append(ItemSeparator);
            }
        }