private void ReadStringValue() { bool quote = false; _propertyQuote = ""; char quoteChar = (char)PeekChar(); if (quoteChar == '"' || quoteChar == '\'') { quote = true; _propertyQuote = quoteChar.ToString(); GetChar(); } _stringBuilder.Remove(0, _stringBuilder.Length); while (true) { GetChar(); if (_charInt == -1 || (quote && (_char == quoteChar || ((_char == '"' || _char == '\'') && PeekChar() == '>'))) || (!quote && (_char == ' ' || _char == '\t' || _char == '\r' || _char == '\n')) || _char == '>' || (_char == '/' && PeekChar() == '>') ) { break; } _stringBuilder.Append(_char); } _propertyValue = _stringBuilder.ToString(); _propertyValue = HtmlCharCodes.TranslateCode(_propertyValue); }
private void ReadText() { int l; bool isTextSeparator = true; bool comment = false; _stringBuilder.Remove(0, _stringBuilder.Length); while (true) { int charInt = PeekChar(); if (!comment && (char)charInt == '<' && (char.IsLetter((char)PeekChar(1)) || (PeekChar(1) == '/' && char.IsLetter((char)PeekChar(2))))) { break; } if (!comment && (char)charInt == '<' && PeekChar(1) == '!' && PeekChar(2) == '-' && PeekChar(3) == '-') { if (!_readCommentInText) { break; } comment = true; GetChar(); _stringBuilder.Append(_char); GetChar(); _stringBuilder.Append(_char); GetChar(); _stringBuilder.Append(_char); GetChar(); _stringBuilder.Append(_char); charInt = PeekChar(); isTextSeparator = false; } if (charInt == -1) { break; } GetChar(); _stringBuilder.Append(_char); if (_char != ' ' && _char != '\t' && _char != '\r' && _char != '\n') { isTextSeparator = false; } l = _stringBuilder.Length; if (comment && l >= 3 && _stringBuilder[l - 3] == '-' && _stringBuilder[l - 2] == '-' && _stringBuilder[l - 1] == '>') { comment = false; } } _text = _stringBuilder.ToString(); _text = HtmlCharCodes.TranslateCode(_text); _isTextSeparator = isTextSeparator; }
private void ReadScript() { _stringBuilder.Remove(0, _stringBuilder.Length); while (true) { int iChar = PeekChar(); if (iChar == -1) { break; } if ((char)iChar == '<' && PeekChar(1) == '/' && char.ToLower((char)PeekChar(2)) == 's' && char.ToLower((char)PeekChar(3)) == 'c' && char.ToLower((char)PeekChar(4)) == 'r' && char.ToLower((char)PeekChar(5)) == 'i' && char.ToLower((char)PeekChar(6)) == 'p' && char.ToLower((char)PeekChar(7)) == 't' && char.ToLower((char)PeekChar(8)) == '>') { break; } GetChar(); _stringBuilder.Append(_char); } _text = _stringBuilder.ToString(); _text = HtmlCharCodes.TranslateCode(_text); }
private void ReadStringValue2() { bool quote = false; _propertyQuote = ""; char quoteChar = (char)PeekChar(); if (quoteChar == '"' || quoteChar == '\'') { quote = true; _propertyQuote = quoteChar.ToString(); GetChar(); } _stringBuilder.Remove(0, _stringBuilder.Length); bool quote2 = quote; int charInt; int i = 0, endQuotePos = -1; while ((charInt = PeekChar(i)) != -1) { char c = (char)charInt; if (quote2) { if (c == quoteChar) { endQuotePos = i; quote2 = false; } } else { if (c == '=') { for (; i >= 0; i--) { c = (char)PeekChar(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { break; } } for (; i >= 0 && (endQuotePos == -1 || i > endQuotePos); i--) { char cChar = (char)PeekChar(i); if (cChar == ' ' || cChar == '\t' || cChar == '\r' || cChar == '\n') { break; } } break; } else if (c == '>') { if (i > 0 && (char)PeekChar(i - 1) == '/') { i--; } i--; break; } else if (c == '<') { i--; break; } } i++; } for (; i >= 0; i--) { char c = (char)PeekChar(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { break; } } if (quote && i >= 0 && (char)PeekChar(i) == quoteChar) { i--; } for (; i >= 0; i--) { GetChar(); _stringBuilder.Append(_char); } _propertyValue = _stringBuilder.ToString(); _propertyValue = HtmlCharCodes.TranslateCode(_propertyValue); }