Exemple #1
0
        private IMessage ParseBinaryData(ListBinaryData binaryData)
        {
            //TODO: maybe always parse even if empty?
            if (binaryData.BinaryData.IsEmpty)
            {
                return(null);
            }

            var descriptor = _binaryDataDescriptorSet.GetDescriptorByIndex(binaryData.DataType);

            return(descriptor.Parser.ParseFrom(binaryData.BinaryData));
        }
Exemple #2
0
        private ListBinaryData CreateBinaryDataFor(Stream stream, NetworkStringList list, int index)
        {
            var binaryData = list.GetBinaryData(index);

            var message = new ListBinaryData();

            if (binaryData != null)
            {
                binaryData.WriteTo(stream);

                stream.Position    = 0;
                message.BinaryData = ByteString.FromStream(stream);
                stream.SetLength(0);

                message.DataType = _binaryDataDescriptorSet.GetDescriptorIndex(binaryData.Descriptor);
            }

            return(message);
        }