Beispiel #1
0
            CompositeSegment ParseInsertionPoint()
            {
                char?formatSpecifier = null;

                if (!TryParse(_compositeFormatString, _currentIndex, 5, out uint arg, out int consumed))
                {
                    throw new Exception("invalid insertion point");
                }
                _currentIndex += consumed;
                if (_currentIndex >= _compositeFormatString.Length)
                {
                    throw new Exception("missing end bracket");
                }

                if (_compositeFormatString[_currentIndex] == ':')
                {
                    _currentIndex++;
                    formatSpecifier = _compositeFormatString[_currentIndex];
                    _currentIndex++;
                }

                if (_compositeFormatString[_currentIndex] != '}')
                {
                    throw new Exception("missing end bracket");
                }

                _currentIndex++;
                var StandardFormat = (formatSpecifier.HasValue && formatSpecifier.Value != 0) ? new StandardFormat(formatSpecifier.Value) : default;

                return(CompositeSegment.InsertionPoint(arg, StandardFormat));
            }
Beispiel #2
0
            CompositeSegment ParseInsertionPoint()
            {
                uint arg;
                int  consumed;
                char?formatSpecifier = null;

                if (!TryParse(_compositeFormatString, _currentIndex, 5, out arg, out consumed))
                {
                    throw new Exception("invalid insertion point");
                }
                _currentIndex += consumed;
                if (_currentIndex >= _compositeFormatString.Length)
                {
                    throw new Exception("missing end bracket");
                }

                if (_compositeFormatString[_currentIndex] == ':')
                {
                    _currentIndex++;
                    formatSpecifier = _compositeFormatString[_currentIndex];
                    _currentIndex++;
                }

                if (_compositeFormatString[_currentIndex] != '}')
                {
                    throw new Exception("missing end bracket");
                }

                _currentIndex++;
                var parsedFormat = formatSpecifier.HasValue ? System.Text.Formatting.Format.Parse(formatSpecifier.Value): default(System.Text.Formatting.Format.Parsed);

                return(CompositeSegment.InsertionPoint(arg, parsedFormat));
            }