Beispiel #1
0
        public void Write(string value, StringPrefixEncoding encoding)
        {
            if (value == null)
            {
                switch (encoding)
                {
                case StringPrefixEncoding.Int16:
                    Write((Int16)(-1));
                    return;

                default:
                    Write(-1);
                    return;
                }
            }

            switch (encoding)
            {
            case StringPrefixEncoding.Int16:
                Write((Int16)value.Length);
                break;

            case StringPrefixEncoding.Int32:
                Write(value.Length);
                break;
            }

            Write(Encoding.UTF8.GetBytes(value));
        }
Beispiel #2
0
        public KafkaMessagePacker Pack(IEnumerable <string> data, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
        {
            foreach (var item in data)
            {
                _stream.Write(item, encoding);
            }

            return(this);
        }
        public KafkaMessagePacker Pack(IEnumerable<string> data, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
        {
            foreach (var item in data)
            {
                _stream.Write(item, encoding);
            }

            return this;
        }
Beispiel #4
0
        public void StringTests(String value, Byte[] expectedBytes, StringPrefixEncoding encoding)
        {
            // arrange
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);

            // act
            binaryWriter.Write(value, encoding);

            // assert
            var actualBytes = memoryStream.ToArray();

            Assert.That(expectedBytes, Is.EqualTo(actualBytes));
        }
Beispiel #5
0
        public void Write(byte[] value, StringPrefixEncoding encoding)
        {
            if (value == null)
            {
                Write(-1);
                return;
            }

            switch (encoding)
            {
            case StringPrefixEncoding.Int16:
                Write((Int16)value.Length);
                break;

            case StringPrefixEncoding.Int32:
                Write(value.Length);
                break;
            }

            Write(value);
        }
        public void Write(string value, StringPrefixEncoding encoding)
        {
            if (value == null)
            {
                switch (encoding)
                {
                    case StringPrefixEncoding.Int16:
                        Write((Int16)(-1));
                        return;

                    default:
                        Write(-1);
                        return;
                }
            }

            switch (encoding)
            {
                case StringPrefixEncoding.Int16:
                    Write((Int16)value.Length);
                    break;

                case StringPrefixEncoding.Int32:
                    Write(value.Length);
                    break;
            }

            Write(Encoding.UTF8.GetBytes(value));
        }
        public void Write(byte[] value, StringPrefixEncoding encoding)
        {
            if (value == null)
            {
                Write(-1);
                return;
            }

            switch (encoding)
            {
                case StringPrefixEncoding.Int16:
                    Write((Int16)value.Length);
                    break;

                case StringPrefixEncoding.Int32:
                    Write(value.Length);
                    break;
            }

            Write(value);
        }
Beispiel #8
0
 public KafkaMessagePacker Pack(string data, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
 {
     _stream.Write(data, encoding);
     return(this);
 }
Beispiel #9
0
 public KafkaMessagePacker Pack(byte[] buffer, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
 {
     _stream.Write(buffer, encoding);
     return(this);
 }
 public KafkaMessagePacker Pack(string data, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
 {
     _stream.Write(data, encoding);
     return this;
 }
 public KafkaMessagePacker Pack(byte[] buffer, StringPrefixEncoding encoding = StringPrefixEncoding.Int32)
 {
     _stream.Write(buffer, encoding);
     return this;
 }
        public void StringTests(String value, Byte[] expectedBytes, StringPrefixEncoding encoding)
        {

            // arrange
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);

            // act
            binaryWriter.Write(value, encoding);

            // assert
            var actualBytes = memoryStream.ToArray();
            Assert.That(expectedBytes, Is.EqualTo(actualBytes));
        }