예제 #1
0
        /// <summary>
        ///     A CSStreamReader extension method that reads start tag.
        /// </summary>
        /// <param name="stream">        The stream to act on. </param>
        /// <param name="key">           [out] The key. </param>
        /// <param name="dimensionInfo"> [out] Information describing the dimension. </param>
        /// <exception cref="CSReaderException">
        ///     Thrown when a Create struct Reader error condition
        ///     occurs.
        /// </exception>
        internal static void ReadStartTag(this CSStreamReader stream, out string key, out string dimensionInfo)
        {
            while (stream.ReadChar(out char c))
            {
                switch (c)
                {
                case '[':
                {
                    stream.ReadStartTagInner(out key, out dimensionInfo);
                    return;
                }

                case '/':
                    throw new CSReaderException($"ERROR: INVALID TAG! -> invalid char '{c}'!");

                case '\n':
                case '\r':
                case '\t':
                case ' ':
                    break;

                default:
                    Console.WriteLine(
                        $"WARNING: invalid char '{c}' found near line {stream.Line} -> index {stream.Index}!");
                    break;
                }
            }
            throw new CSReaderException("ERROR: NO START TAG FOUND -> \'[:]\'");
        }