Reverse() static private méthode

Reverses the order of bytes in the array
static private Reverse ( byte bytes ) : void
bytes byte
Résultat void
Exemple #1
0
 /// <summary>
 /// Reads a float field from the stream.
 /// </summary>
 public float ReadFloat()
 {
     if (BitConverter.IsLittleEndian && 4 <= bufferSize - bufferPos)
     {
         float ret = BitConverter.ToSingle(buffer, bufferPos);
         bufferPos += 4;
         return(ret);
     }
     else
     {
         byte[] rawBytes = ReadRawBytes(4);
         if (!BitConverter.IsLittleEndian)
         {
             ByteArray.Reverse(rawBytes);
         }
         return(BitConverter.ToSingle(rawBytes, 0));
     }
 }
Exemple #2
0
        /// <summary>
        /// Writes a float field value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteFloat(float value)
        {
            byte[] rawBytes = BitConverter.GetBytes(value);
            if (!BitConverter.IsLittleEndian)
            {
                ByteArray.Reverse(rawBytes);
            }

            if (limit - position >= 4)
            {
                buffer[position++] = rawBytes[0];
                buffer[position++] = rawBytes[1];
                buffer[position++] = rawBytes[2];
                buffer[position++] = rawBytes[3];
            }
            else
            {
                WriteRawBytes(rawBytes, 0, 4);
            }
        }
Exemple #3
0
        public void WriteFloat(float value)
        {
            byte[] array = CodedOutputStream.smethod_3(value);
            while (true)
            {
IL_14C:
                uint arg_11B_0 = 1042150926u;
                while (true)
                {
                    uint num;
                    switch ((num = (arg_11B_0 ^ 1022855066u)) % 9u)
                    {
                    case 0u:
                    {
                        byte[] arg_ED_0 = this.buffer;
                        int    num2     = this.position;
                        this.position  = num2 + 1;
                        arg_ED_0[num2] = array[0];
                        byte[] arg_108_0 = this.buffer;
                        num2            = this.position;
                        this.position   = num2 + 1;
                        arg_108_0[num2] = array[1];
                        arg_11B_0       = (num * 458216763u ^ 884498142u);
                        continue;
                    }

                    case 1u:
                        return;

                    case 2u:
                        goto IL_14C;

                    case 4u:
                    {
                        byte[] arg_A8_0 = this.buffer;
                        int    num2     = this.position;
                        this.position  = num2 + 1;
                        arg_A8_0[num2] = array[2];
                        byte[] arg_C3_0 = this.buffer;
                        num2           = this.position;
                        this.position  = num2 + 1;
                        arg_C3_0[num2] = array[3];
                        arg_11B_0      = (num * 2383484455u ^ 688700656u);
                        continue;
                    }

                    case 5u:
                        this.WriteRawBytes(array, 0, 4);
                        arg_11B_0 = 1532374059u;
                        continue;

                    case 6u:
                        arg_11B_0 = ((this.limit - this.position < 4) ? 842348969u : 206970980u);
                        continue;

                    case 7u:
                        ByteArray.Reverse(array);
                        arg_11B_0 = (num * 1074657787u ^ 895898004u);
                        continue;

                    case 8u:
                        arg_11B_0 = ((BitConverter.IsLittleEndian ? 4106246718u : 3865512180u) ^ num * 3960773342u);
                        continue;
                    }
                    goto Block_3;
                }
            }
            Block_3 :;
        }