Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* THIS FILE HAS BEEN GENERATED BY A TOOL !!!
- * DO NOT EDIT THIS FILE AS ALL CHANGES WILL BE LOST DURING THE NEXT BUILD */
- using System;
- using System.IO;
- using System.Collections;
- using Arendee.Protobuf_Micro.Extensions;
- namespace Signax.DistributedDisplayProtocol
- {
- public class BeginDownloadingFileRequest : IProtocolMessage
- {
- private static ushort PAYLOAD_IDENTIFIER = 0x0005;
- public ushort PayloadIdentifier
- {
- get
- {
- return PAYLOAD_IDENTIFIER;
- }
- }
- public string Path { get; set; }
- public uint BlockSize { get; set; }
- public uint Address { get; set; }
- public BeginDownloadingFileRequest()
- {
- BlockSize = 1024;
- Address = 1;
- }
- public static BeginDownloadingFileRequest Decode(Stream stream)
- {
- var message = new BeginDownloadingFileRequest();
- uint repeatedLength = 0;
- while (stream.Position < stream.Length)
- {
- var tag = stream.ReadTag();
- switch (tag.Id)
- {
- case 1:
- message.Path = stream.ReadLengthDelimitedString();
- break;
- case 2:
- message.BlockSize = stream.ReadVarUInt32();
- break;
- case 15:
- message.Address = stream.ReadVarUInt32();
- break;
- default:
- break;
- }
- }
- return message;
- }
- //When the message is part of a repeated field
- public static BeginDownloadingFileRequest Decode(Stream stream, uint length)
- {
- var message = new BeginDownloadingFileRequest();
- long carret = 0;
- while (stream.Position < stream.Length && carret < length)
- {
- var initialPosition = stream.Position;
- var tag = stream.ReadTag();
- uint repeatedLength = 0;
- switch (tag.Id)
- {
- case 1:
- message.Path = stream.ReadLengthDelimitedString();
- break;
- case 2:
- message.BlockSize = stream.ReadVarUInt32();
- break;
- case 15:
- message.Address = stream.ReadVarUInt32();
- break;
- default:
- break;
- }
- carret += stream.Position - initialPosition;
- }
- return message;
- }
- public static BeginDownloadingFileRequest Decode(byte[] data)
- {
- using (var stream = new MemoryStream(data))
- {
- return BeginDownloadingFileRequest.Decode(stream);
- }
- }
- public Stream Encode(Stream stream)
- {
- stream.WriteLengthDelimitedStringWithTag(1, Path);
- if (BlockSize != 1024)
- stream.WriteVarUInt32WithTag(2, BlockSize);
- if (Address != 1)
- stream.WriteVarUInt32WithTag(15, Address);
- return stream;
- }
- public byte[] Encode()
- {
- using (var stream = new MemoryStream())
- {
- return ((MemoryStream)Encode(stream)).ToArray();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement