Exemplo n.º 1
0
        private void ReadStringValue()
        {
            bool bQuote = false;

            _propertyQuote = "";
            char cQuote = (char)PeekChar();

            if (cQuote == '"' || cQuote == '\'')
            {
                bQuote         = true;
                _propertyQuote = cQuote.ToString();
                GetChar();
            }

            _stringBuilder.Remove(0, _stringBuilder.Length);
            while (true)
            {
                GetChar();
                if (_charInt == -1 ||
                    (bQuote && (_char == cQuote || ((_char == '"' || _char == '\'') && PeekChar() == '>'))) ||
                    (!bQuote && (_char == ' ' || _char == '\t' || _char == '\r' || _char == '\n')) ||
                    _char == '>' || (_char == '/' && PeekChar() == '>')
                    )
                {
                    break;
                }
                _stringBuilder.Append(_char);
            }
            _propertyValue = _stringBuilder.ToString();
            _propertyValue = Http_v1.TranslateCode(_propertyValue);
        }
Exemplo n.º 2
0
        private void Open()
        {
            _readInProgress = false;
            if (_urlPath != null)
            {
                if (_urlPath.StartsWith("http:") || _urlPath.StartsWith("file:"))
                {
                    //WebClient client = new WebClient();
                    //client.Headers.Add(HttpRequestHeader.UserAgent, "");
                    ////cTrace.StartNestedLevel("WebClient.OpenRead");
                    //Stream st = client.OpenRead(gsUrl_Path);
                    ////cTrace.StopLevel();
                    //gtr = new StreamReader(st, gEncoding);

                    Http_v1 http = new Http_v1(_urlPath);
                    //gtr = new StreamReader(http.WebStream, gEncoding);
                    _tr = http.WebStream;
                }
                else
                {
                    _fs = new FileStream(_urlPath, FileMode.Open, FileAccess.Read, FileShare.Read, _bufferSize);
                    _tr = new StreamReader(_fs, _encoding);
                }
            }
            //else if (gStream != null)
            //{
            //    gtr = new StreamReader(gStream, gEncoding);
            //}
        }
Exemplo n.º 3
0
        private void ReadText()
        {
            int l;

            bool bIsTextSeparator = true;
            bool bComment         = false;

            _stringBuilder.Remove(0, _stringBuilder.Length);
            while (true)
            {
                int iChar = PeekChar();
                if (!bComment && (char)iChar == '<' && (char.IsLetter((char)PeekChar(1)) || (PeekChar(1) == '/' && char.IsLetter((char)PeekChar(2)))))
                {
                    break;
                }
                if (!bComment && (char)iChar == '<' && PeekChar(1) == '!' && PeekChar(2) == '-' && PeekChar(3) == '-')
                {
                    if (!_readCommentInText)
                    {
                        break;
                    }
                    bComment = true;
                    GetChar(); _stringBuilder.Append(_char);
                    GetChar(); _stringBuilder.Append(_char);
                    GetChar(); _stringBuilder.Append(_char);
                    GetChar(); _stringBuilder.Append(_char);
                    iChar            = PeekChar();
                    bIsTextSeparator = false;
                }

                if (iChar == -1)
                {
                    break;
                }
                GetChar();
                _stringBuilder.Append(_char);
                if (_char != ' ' && _char != '\t' && _char != '\r' && _char != '\n')
                {
                    bIsTextSeparator = false;
                }
                l = _stringBuilder.Length;
                if (bComment && l >= 3 && _stringBuilder[l - 3] == '-' && _stringBuilder[l - 2] == '-' && _stringBuilder[l - 1] == '>')
                {
                    bComment = false;
                }
            }
            _text            = _stringBuilder.ToString();
            _text            = Http_v1.TranslateCode(_text);
            _isTextSeparator = bIsTextSeparator;
        }
Exemplo n.º 4
0
 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 = Http_v1.TranslateCode(_text);
 }
Exemplo n.º 5
0
        private void ReadStringValue2()
        {
            bool bQuote = false;

            _propertyQuote = "";
            char cQuote = (char)PeekChar();

            if (cQuote == '"' || cQuote == '\'')
            {
                bQuote         = true;
                _propertyQuote = cQuote.ToString();
                GetChar();
            }

            _stringBuilder.Remove(0, _stringBuilder.Length);

            bool bQuote2 = bQuote;
            int  iChar;
            int  i = 0, iEndQuote = -1;

            while ((iChar = PeekChar(i)) != -1)
            {
                char c = (char)iChar;
                if (bQuote2)
                {
                    if (c == cQuote)
                    {
                        iEndQuote = i;
                        bQuote2   = false;
                    }
                }
                else
                {
                    if (c == '=')
                    {
                        for (; i >= 0; i--)
                        {
                            c = (char)PeekChar(i);
                            if (c != ' ' && c != '\t' && c != '\r' && c != '\n')
                            {
                                break;
                            }
                        }
                        for (; i >= 0 && (iEndQuote == -1 || i > iEndQuote); 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 (bQuote && i >= 0 && (char)PeekChar(i) == cQuote)
            {
                i--;
            }

            for (; i >= 0; i--)
            {
                GetChar();
                _stringBuilder.Append(_char);
            }

            _propertyValue = _stringBuilder.ToString();
            _propertyValue = Http_v1.TranslateCode(_propertyValue);
        }
Exemplo n.º 6
0
		private void Open()
		{
            _readInProgress = false;
            if (_urlPath != null)
            {
                if (_urlPath.StartsWith("http:") || _urlPath.StartsWith("file:"))
                {
                    //WebClient client = new WebClient();
                    //client.Headers.Add(HttpRequestHeader.UserAgent, "");
                    ////cTrace.StartNestedLevel("WebClient.OpenRead");
                    //Stream st = client.OpenRead(gsUrl_Path);
                    ////cTrace.StopLevel();
                    //gtr = new StreamReader(st, gEncoding);

                    Http_v1 http = new Http_v1(_urlPath);
                    //gtr = new StreamReader(http.WebStream, gEncoding);
                    _tr = http.WebStream;
                }
                else
                {
                    _fs = new FileStream(_urlPath, FileMode.Open, FileAccess.Read, FileShare.Read, _bufferSize);
                    _tr = new StreamReader(_fs, _encoding);
                }
            }
            //else if (gStream != null)
            //{
            //    gtr = new StreamReader(gStream, gEncoding);
            //}
        }