Ejemplo n.º 1
0
        public DateTime ValueAsDateTime()
        {
            long seconds = 0;

            if (_Length == 1)
            {
                seconds = _Value[0];
            }
            else if (_Length == 2)
            {
                seconds = NetworkByteOrderConverter.ToInt16(_Value, 0);
            }
            else if (_Length == 3)
            {
                byte[] buffer = new byte[4];
                Buffer.BlockCopy(_Value, 0, buffer, 1, 3);
                seconds = NetworkByteOrderConverter.ToInt32(buffer, 0);
            }
            else if (_Length == 4)
            {
                seconds = NetworkByteOrderConverter.ToInt32(_Value, 0);
            }
            else if (_Length == 8)
            {
                seconds = NetworkByteOrderConverter.ToInt64(_Value, 0);
            }
            else
            {
                throw new InvalidCastException();
            }
            return(_Epoch.AddSeconds(seconds));
        }
Ejemplo n.º 2
0
        public long ValueAsInt64()
        {
            long result;

            if (_Length == 1)
            {
                result = _Value[0];
            }
            else if (_Length == 2)
            {
                result = NetworkByteOrderConverter.ToInt16(_Value, 0);
            }
            else if (_Length == 4)
            {
                result = NetworkByteOrderConverter.ToInt32(_Value, 0);
            }
            else if (_Length == 8)
            {
                result = NetworkByteOrderConverter.ToInt64(_Value, 0);
            }
            else
            {
                throw new InvalidCastException();
            }
            return(result);
        }