예제 #1
0
        private async Task ReadMessagePropertiesAsync(ProtobufReader reader, T message)
        {
            var num = 0;

            while (reader.State != ProtobufReaderState.EndOfMessage)
            {
                PropertyReader <T> propertyReader;
                if (propertyReaders.TryGetValue(reader.FieldNumber, out propertyReader))
                {
                    try
                    {
                        num++;
                        await propertyReader.Read(reader, message);
                    }
                    catch (Exception e)
                    {
                        throw new InvalidOperationException("", e);
                    }
                }
                else
                {
                    await reader.SkipAsync();
                }
            }
        }
예제 #2
0
        public async Task <OsmHeader> ReadHeader()
        {
            await reader.BeginReadMessageAsync(length);

            var header = new OsmHeader();

            while (reader.State == ProtobufReaderState.Field)
            {
                switch (reader.FieldNumber)
                {
                case 1:
                    header.BoundBox = await ParseBoundBoxAsync();

                    break;

                case 4:
                    header.RequiredFeatures = await reader.ReadStringAsync();

                    break;

                case 5:
                    header.OptionalFeatures = await reader.ReadStringAsync();

                    break;

                case 16:
                    header.WritingProgram = await reader.ReadStringAsync();

                    break;

                case 17:
                    header.Source = await reader.ReadStringAsync();

                    break;

                default:
                    await reader.SkipAsync();

                    break;
                }
            }
            await reader.EndReadMessageAsync();

            return(header);
        }