25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
-
- namespace MQTTnet.Core.Serializer
- {
- public sealed class ByteWriter
- {
- private int _index;
- private int _byte;
-
- public byte Value => (byte)_byte;
-
- public void Write(int @byte, int count)
- {
- for (var i = 0; i < count; i++)
- {
- var value = ((1 << i) & @byte) > 0;
- Write(value);
- }
- }
-
- public void Write(bool bit)
- {
- if (_index >= 8)
- {
- throw new InvalidOperationException("End of the byte reached.");
- }
-
- if (bit)
- {
- _byte |= 1 << _index;
- }
-
- _index++;
- }
- }
- }
|