GetBytes() публичный статический метод

public static GetBytes ( bool value ) : byte[]
value bool
Результат byte[]
Пример #1
0
        public void Update(Session session, JET_DBID dbid, Action <string> output)
        {
            using (var table = new Table(session, dbid, "indexes_stats", OpenTableGrbit.None))
            {
                byte[]       defaultValue = BitConverter.GetBytes(1);
                JET_COLUMNID columnid;
                Api.JetAddColumn(session, table, "priority", new JET_COLUMNDEF
                {
                    coltyp = JET_coltyp.Long,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);

                defaultValue = BitConverter.GetBytes(0);
                Api.JetAddColumn(session, table, "created_timestamp", new JET_COLUMNDEF
                {
                    cbMax  = 8, //64 bits
                    coltyp = JET_coltyp.Binary,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);

                Api.JetAddColumn(session, table, "last_indexing_time", new JET_COLUMNDEF
                {
                    cbMax  = 8,                    //64 bits
                    coltyp = JET_coltyp.Binary,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);
            }

            SchemaCreator.UpdateVersion(session, dbid, "4.6");
        }
Пример #2
0
        public static ASN1 FromInt32(Int32 value)
        {
            byte[] integer = BitConverterLE.GetBytes(value);
            Array.Reverse(integer);
            int x = 0;

            while ((x < integer.Length) && (integer[x] == 0x00))
            {
                x++;
            }
            ASN1 asn1 = new ASN1(0x02);

            switch (x)
            {
            case 0:
                asn1.Value = integer;
                break;

            case 4:
                asn1.Value = new byte[1];
                break;

            default:
                byte[] smallerInt = new byte[4 - x];
                Buffer.BlockCopy(integer, x, smallerInt, 0, smallerInt.Length);
                asn1.Value = smallerInt;
                break;
            }
            return(asn1);
        }
Пример #3
0
            public void Randomize(double num)
            {
                int num1 = _seed;
                int num2 = !BitConverter.IsLittleEndian ? BitConverter.ToInt32(BitConverter.GetBytes(num), 0) : BitConverter.ToInt32(BitConverter.GetBytes(num), 4);
                int num3 = (num2 & (int)ushort.MaxValue ^ num2 >> 16) << 8;
                int num4 = num1 & -16776961 | num3;

                _seed = num4;
            }
Пример #4
0
        public byte[] GetHeaderPage()
        {
            _byteIterator = 0;
            var headerPage = new byte[Static.PageSize];

            Array.Copy(BC.GetBytes(RootIndex), 0, headerPage, _byteIterator, sizeof(long));
            _byteIterator += sizeof(long);

            return(headerPage);
        }
Пример #5
0
            public void Randomize()
            {
                System.DateTime now   = System.DateTime.Now;
                float           timer = (float)checked ((60 * now.Hour + now.Minute) * 60 + now.Second) + (float)now.Millisecond / 1000f;
                int             num1  = _seed;
                int             num2  = BitConverter.ToInt32(BitConverter.GetBytes(timer), 0);
                int             num3  = (num2 & (int)ushort.MaxValue ^ num2 >> 16) << 8;
                int             num4  = num1 & -16776961 | num3;

                _seed = num4;
            }
Пример #6
0
    private static void TransferHeaders(Socket socket, int txDataLen, out int rxDataLen)
    {
        socket.Blocking = true;
        socket.Send(BitConverter.GetBytes(txDataLen));
        byte[] buf4 = new byte[4];
        int    len  = socket.Receive(buf4);

        if (len != 4)
        {
            throw new ApplicationException("Incomplete header received, len=" + len);
        }
        rxDataLen = BitConverter.ToInt32(buf4, 0);
    }
Пример #7
0
 public void WriteRpcLog(int gameCode, string ipAddress, Shared.RpcCalls rpcCall, byte[] data)
 {
     if (data.Length > 240)
     {
         throw new Exception("Too much data. Please write max. 255 bytes at a time.");
     }
     BeginWriteLine((byte)Shared.LogType.Rpc, GetTime());
     EncodeStream.WriteByte((byte)rpcCall);
     EncodeStream.Write(BitConverter.GetBytes(gameCode), 0, 4);
     EncodeStream.Write((IPAddress.Parse(ipAddress).GetAddressBytes()), 0, 4);
     EncodeStream.Write(data, 0, data.Length);
     EndWriteLine();
 }
Пример #8
0
            public float VBNext(float num)
            {
                int num1 = _seed;

                if ((double)num != 0.0)
                {
                    if ((double)num < 0.0)
                    {
                        long num2 = (long)BitConverter.ToInt32(BitConverter.GetBytes(num), 0) & (long)uint.MaxValue;
                        num1 = checked ((int)(num2 + (num2 >> 24) & 16777215L));
                    }
                    num1 = checked ((int)((long)num1 * 1140671485L + 12820163L & 16777215L));
                }
                _seed = num1;
                return((float)num1 / 1.677722E+07f);
            }
Пример #9
0
        public byte[] GetDataPage()
        {
            _byteIterator = 0;
            UsedSpace     = Records.Count;

            var page = new byte[Static.PageSize];

            Array.Copy(BC.GetBytes(UsedSpace), 0, page, _byteIterator, sizeof(int));
            _byteIterator += sizeof(int);


            for (var i = 0; i < UsedSpace; i++)
            {
                Array.Copy(BC.GetBytes(Records[i].Key), 0, page, _byteIterator, sizeof(uint));
                _byteIterator += sizeof(uint);
                Array.Copy(BC.GetBytes(Records[i].Radius), 0, page, _byteIterator, sizeof(double));
                _byteIterator += sizeof(double);
                Array.Copy(BC.GetBytes(Records[i].Angle), 0, page, _byteIterator, sizeof(short));
                _byteIterator += sizeof(short);
            }

            return(page);
        }
Пример #10
0
        public byte[] GetBTreePage()
        {
            _byteIterator = 0;
            var page = new byte[Static.PageSize];

            _presentRecords = Records.Count;

            Array.Copy(BC.GetBytes(ParentIndex), 0, page, _byteIterator, sizeof(long));
            _byteIterator += sizeof(long);
            Array.Copy(BC.GetBytes(SelfIndex), 0, page, _byteIterator, sizeof(long));
            _byteIterator += sizeof(long);
            Array.Copy(BC.GetBytes(_presentRecords), 0, page, _byteIterator, sizeof(long));
            _byteIterator += sizeof(long);
            Array.Copy(BC.GetBytes(IsLeaf), 0, page, _byteIterator, sizeof(bool));
            _byteIterator += sizeof(bool);

            for (var i = 0; i < _presentRecords; i++)
            {
                var key       = BC.GetBytes(Records[i].Key);
                var pageIndex = BC.GetBytes(Records[i].RecordIndex);

                Array.Copy(key, 0, page, _byteIterator, sizeof(long));
                _byteIterator += sizeof(long);
                Array.Copy(pageIndex, 0, page, _byteIterator, sizeof(long));
                _byteIterator += sizeof(long);
            }
            if (!IsLeaf)
            {
                for (var i = 0; i < _presentRecords + 1; i++)
                {
                    Array.Copy(BC.GetBytes(Childrens[i]), 0, page, _byteIterator, sizeof(long));
                    _byteIterator += sizeof(long);
                }
            }

            return(page);
        }
Пример #11
0
 private void BeginWriteLine(byte logType, UInt64 unixTimeMs)
 {
     EncodeStream.WriteByte(logType);
     EncodeStream.Write(BitConverter.GetBytes(unixTimeMs), 0, 8);
 }
Пример #12
0
 /// <summary>
 /// Returns the specified half-precision floating point value as an array of bytes.
 /// </summary>
 /// <param name="value">The number to convert.</param>
 /// <returns>An array of bytes with length 2.</returns>
 public static byte[] GetBytes(Half value)
 {
     return(BitConverter.GetBytes(value.value));
 }