Exemple #1
0
        private void SerializeType(BitWriter bitWriter, ulong value, int bitLength)
        {
            var bytes = BitConverter.GetBytes((uint)value).Reverse().ToArray();

            bitWriter.WriteBits(bytes, bitLength, offset: 32 - bitLength);
        }
Exemple #2
0
        private void SerializeType(BitWriter bitWriter, string value)
        {
            var bytes = FloEncoding.GetBytes(value, onlyCharacters: true);

            bitWriter.WriteBits(bytes, value.Length * 5);
        }
Exemple #3
0
        private void SerializeType(BitWriter bitWriter, double value)
        {
            var bytes = BitConverter.GetBytes((float)value).Reverse().ToArray();

            bitWriter.WriteBits(bytes, length: 31, offset: 1); // cut off sign bit because it's always positive
        }
        private void SerializeType(BitWriter bitWriter, string value, bool onlyCharacters = false)
        {
            var bytes = FloEncoding.GetBytes(value, onlyCharacters);

            bitWriter.WriteBits(bytes, value.Length * (onlyCharacters ? 5 : 6));
        }