ToBytes() static public méthode

static public ToBytes ( string value ) : byte[]
value string
Résultat byte[]
Exemple #1
0
        public byte[] GetString(out int offset, out int length)
        {
            StringHandleType type = _type;

            if (type == StringHandleType.UTF8)
            {
                offset = _offset;
                length = _length;
                return(_bufferReader.Buffer);
            }
            if (type == StringHandleType.Dictionary)
            {
                byte[] buffer = _bufferReader.GetDictionaryString(_key).ToUTF8();
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            if (type == StringHandleType.ConstString)
            {
                byte[] buffer = XmlConverter.ToBytes(s_constStrings[_key]);
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            else
            {
                DiagnosticUtility.DebugAssert(type == StringHandleType.EscapedUTF8, "");
                byte[] buffer = XmlConverter.ToBytes(_bufferReader.GetEscapedString(_offset, _length));
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
        }
Exemple #2
0
        public byte[] GetString(out int offset, out int length)
        {
            switch (this.type)
            {
            case StringHandleType.UTF8:
                offset = this.offset;
                length = this.length;
                return(this.bufferReader.Buffer);

            case StringHandleType.Dictionary:
            {
                byte[] buffer = this.bufferReader.GetDictionaryString(this.key).ToUTF8();
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }

            case StringHandleType.ConstString:
            {
                byte[] buffer2 = XmlConverter.ToBytes(constStrings[this.key]);
                offset = 0;
                length = buffer2.Length;
                return(buffer2);
            }
            }
            byte[] buffer3 = XmlConverter.ToBytes(this.bufferReader.GetEscapedString(this.offset, this.length));
            offset = 0;
            length = buffer3.Length;
            return(buffer3);
        }
        public byte[] GetString(out int offset, out int length)
        {
            StringHandleType type = this.type;

            if (type == StringHandleType.UTF8)
            {
                offset = this.offset;
                length = this.length;
                return(bufferReader.Buffer);
            }
            if (type == StringHandleType.Dictionary)
            {
                byte[] buffer = bufferReader.GetDictionaryString(this.key).ToUTF8();
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            if (type == StringHandleType.ConstString)
            {
                byte[] buffer = XmlConverter.ToBytes(constStrings[key]);
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
            else
            {
                Fx.Assert(type == StringHandleType.EscapedUTF8, "");
                byte[] buffer = XmlConverter.ToBytes(bufferReader.GetEscapedString(this.offset, this.length));
                offset = 0;
                length = buffer.Length;
                return(buffer);
            }
        }