Пример #1
0
        private string NormalizeAttributeValue(byte[] buf, int offset, int length)
        {
            if (length == 0)
                return null;

            string val = null;
            BufferAggregate buffer = new BufferAggregate();
            byte[] copy = new byte[length];
            System.Buffer.BlockCopy(buf, offset, copy, 0, length);
            buffer.Write(copy);
            byte[] b = buffer.GetBuffer();
            int off = 0;
            TOK tok = TOK.END_TAG;
            ContentToken ct = new ContentToken();
            try
            {
                while (off < b.Length)
                {
                    //tok = m_enc.tokenizeContent(b, off, b.Length, ct);
                    tok = m_enc.tokenizeAttributeValue(b, off, b.Length, ct);

                    switch (tok)
                    {
                        case TOK.ATTRIBUTE_VALUE_S:
                        case TOK.DATA_CHARS:
                        case TOK.DATA_NEWLINE:
                            val += (utf.GetString(b, off, ct.TokenEnd - off));
                            break;
                        case TOK.CHAR_REF:
                        case TOK.MAGIC_ENTITY_REF:
                            val += new string(new char[] { ct.RefChar1 });
                            break;
                        case TOK.CHAR_PAIR_REF:
                            val += new string(new char[] {ct.RefChar1, ct.RefChar2});
                            break;
                        case TOK.ENTITY_REF:
            #if CF
                            throw new util.NotImplementedException("Token type not implemented: " + tok);
            #else
                            throw new System.NotImplementedException("Token type not implemented: " + tok);
            #endif
                    }
                    off = ct.TokenEnd;
                }
            }
            catch (PartialTokenException)
            {
                // ignored;
            }
            catch (ExtensibleTokenException)
            {
                // ignored;
            }
            catch (Exception ex)
            {
                if (OnStreamError != null)
                    OnStreamError(this, ex);
            }
            finally
            {
                buffer.Clear(off);
            }
            return val;
        }
Пример #2
0
        /// <summary>
        /// Reset the XML Stream
        /// </summary>
        public void Reset()
        {
            m_Depth		= 0;
            m_root		= null;
            current		= null;
            m_cdata		= false;

            m_buf   = null;
            m_buf	= new BufferAggregate();

            //m_buf.Clear(0);
            m_ns.Clear();
        }