WhichNextInsensitive() public method

Advances the stream until one of the strings passed in is encountered (using a case insensitive compare). Returns which of strings was encountered.
public WhichNextInsensitive ( StringBuilder rejected ) : string
rejected StringBuilder
return string
Example #1
0
        internal static Block ParseDirective(ParserStream stream)
        {
            const string import       = "import";
            const string @using       = "using";
            const string sprite       = "sprite";
            const string charset      = "charset";
            const string media        = "media";
            const string keyframes    = "keyframes";
            const string mozKeyframes = "-moz-keyframes";
            const string webKeyframes = "-webkit-keyframes";
            const string fontFace     = "font-face";
            const string reset        = "reset";

            stream.Advance(); // Advance past @

            var bufferStart = stream.Position;
            var buffer      = new StringBuilder();
            var next        = stream.WhichNextInsensitive(buffer, @using, sprite, import, charset, media, keyframes, mozKeyframes, webKeyframes, fontFace, reset);

            if (next == @using)
            {
                return(ParseUsingDirective(stream));
            }

            if (next == sprite)
            {
                return(ParseSpriteDeclaration(stream));
            }

            if (next == import)
            {
                return(ParseImportDirective(stream));
            }

            if (next == charset)
            {
                return(ParseCharsetDirective(stream));
            }

            if (next == media)
            {
                return(ParseMediaDirective(stream));
            }

            if (next.In(keyframes, mozKeyframes, webKeyframes))
            {
                string prefix = "";
                if (next == mozKeyframes)
                {
                    prefix = "-moz-";
                }
                if (next == webKeyframes)
                {
                    prefix = "-webkit-";
                }

                return(ParseKeyFramesDirective(prefix, stream, bufferStart));
            }

            if (next == fontFace)
            {
                return(ParseFontFace(stream, bufferStart));
            }

            if (next == reset)
            {
                return(ParseResetDirective(stream, bufferStart));
            }

            stream.PushBack(buffer.ToString());

            var leader = new StringBuilder();

            var eqOrPara = stream.ScanUntil(leader, '=', '(');

            if (eqOrPara == '=')
            {
                return(ParseMoreVariable(leader.ToString(), stream, bufferStart));
            }

            return(ParseMixinDeclaration(leader.ToString(), stream));
        }
Example #2
0
        internal static Block ParseDirective(ParserStream stream)
        {
            const string import = "import";
            const string @using = "using";
            const string sprite = "sprite";
            const string charset = "charset";
            const string media = "media";
            const string keyframes = "keyframes";
            const string mozKeyframes = "-moz-keyframes";
            const string webKeyframes = "-webkit-keyframes";
            const string fontFace = "font-face";
            const string reset = "reset";

            stream.Advance(); // Advance past @

            var bufferStart = stream.Position;
            var buffer = new StringBuilder();
            var next = stream.WhichNextInsensitive(buffer, @using, sprite, import, charset, media, keyframes, mozKeyframes, webKeyframes, fontFace, reset);

            if (next == @using)
            {
                return ParseUsingDirective(stream);
            }

            if (next == sprite)
            {
                return ParseSpriteDeclaration(stream);
            }

            if (next == import)
            {
                return ParseImportDirective(stream);
            }

            if (next == charset)
            {
                return ParseCharsetDirective(stream);
            }

            if (next == media)
            {
                return ParseMediaDirective(stream);
            }

            if (next.In(keyframes, mozKeyframes, webKeyframes))
            {
                string prefix = "";
                if (next == mozKeyframes) prefix = "-moz-";
                if (next == webKeyframes) prefix = "-webkit-";

                return ParseKeyFramesDirective(prefix, stream, bufferStart);
            }

            if (next == fontFace)
            {
                return ParseFontFace(stream, bufferStart);
            }

            if (next == reset)
            {
                return ParseResetDirective(stream, bufferStart);
            }

            stream.PushBack(buffer.ToString());

            var leader = new StringBuilder();

            var eqOrPara = stream.ScanUntil(leader, '=', '(');

            if (eqOrPara == '=')
            {
                return ParseMoreVariable(leader.ToString(), stream, bufferStart);
            }

            return ParseMixinDeclaration(leader.ToString(), stream);
        }