示例#1
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);
        }
示例#2
0
        public async Task <T> ReadMessageAsync(ProtobufReader reader, long size)
        {
            var message = new T();
            await reader.BeginReadMessageAsync(size);

            await ReadMessagePropertiesAsync(reader, message);

            await reader.EndReadMessageAsync();

            return(message);
        }