ToInt64() static public method

static public ToInt64 ( byte buffer, int offset, int count ) : System.Int64
buffer byte
offset int
count int
return System.Int64
Exemplo n.º 1
0
        public long ToLong()
        {
            ValueHandleType type = _type;

            if (type == ValueHandleType.Zero)
            {
                return(0);
            }
            if (type == ValueHandleType.One)
            {
                return(1);
            }
            if (type == ValueHandleType.Int8)
            {
                return(GetInt8());
            }
            if (type == ValueHandleType.Int16)
            {
                return(GetInt16());
            }
            if (type == ValueHandleType.Int32)
            {
                return(GetInt32());
            }
            if (type == ValueHandleType.Int64)
            {
                return(GetInt64());
            }
            if (type == ValueHandleType.UInt64)
            {
                ulong value = GetUInt64();
                if (value <= long.MaxValue)
                {
                    return((long)value);
                }
            }
            if (type == ValueHandleType.UTF8)
            {
                return(XmlConverter.ToInt64(_bufferReader.Buffer, _offset, _length));
            }
            return(XmlConverter.ToInt64(GetString()));
        }
Exemplo n.º 2
0
        public long ToLong()
        {
            switch (this.type)
            {
            case ValueHandleType.Zero:
                return(0L);

            case ValueHandleType.One:
                return(1L);

            case ValueHandleType.Int8:
                return((long)this.GetInt8());

            case ValueHandleType.Int16:
                return((long)this.GetInt16());

            case ValueHandleType.Int32:
                return((long)this.GetInt32());

            case ValueHandleType.Int64:
                return(this.GetInt64());

            case ValueHandleType.UInt64:
            {
                ulong num = this.GetUInt64();
                if (num <= 0x7fffffffffffffffL)
                {
                    return((long)num);
                }
                break;
            }

            case ValueHandleType.UTF8:
                return(XmlConverter.ToInt64(this.bufferReader.Buffer, this.offset, this.length));
            }
            return(XmlConverter.ToInt64(this.GetString()));
        }