コード例 #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);
        }
コード例 #2
0
        private void SerializeType(BitWriter bitWriter, string value)
        {
            var bytes = FloEncoding.GetBytes(value, onlyCharacters: true);

            bitWriter.WriteBits(bytes, value.Length * 5);
        }
コード例 #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
        }
コード例 #4
0
        private void SerializeType(BitWriter bitWriter, string value, bool onlyCharacters = false)
        {
            var bytes = FloEncoding.GetBytes(value, onlyCharacters);

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