public static DisconnectNotification DeserializeLengthDelimited(Stream stream)
        {
            DisconnectNotification disconnectNotification = new DisconnectNotification();

            DisconnectNotification.DeserializeLengthDelimited(stream, disconnectNotification);
            return(disconnectNotification);
        }
        public static DisconnectNotification DeserializeLengthDelimited(Stream stream, DisconnectNotification instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.Position;
            return(DisconnectNotification.Deserialize(stream, instance, num));
        }
 public static void Serialize(Stream stream, DisconnectNotification instance)
 {
     stream.WriteByte(8);
     ProtocolParser.WriteUInt32(stream, instance.ErrorCode);
     if (instance.HasReason)
     {
         stream.WriteByte(18);
         ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Reason));
     }
 }
 public static DisconnectNotification Deserialize(Stream stream, DisconnectNotification instance, long limit)
 {
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 8)
             {
                 if (num2 != 18)
                 {
                     Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                     uint field = key.Field;
                     if (field == 0u)
                     {
                         throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                     }
                     ProtocolParser.SkipKey(stream, key);
                 }
                 else
                 {
                     instance.Reason = ProtocolParser.ReadString(stream);
                 }
             }
             else
             {
                 instance.ErrorCode = ProtocolParser.ReadUInt32(stream);
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Пример #5
0
        public override bool Equals(object obj)
        {
            DisconnectNotification disconnectNotification = obj as DisconnectNotification;

            if (disconnectNotification == null)
            {
                return(false);
            }
            if (!this.ErrorCode.Equals(disconnectNotification.ErrorCode))
            {
                return(false);
            }
            if (this.HasReason == disconnectNotification.HasReason && (!this.HasReason || this.Reason.Equals(disconnectNotification.Reason)))
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
 public static DisconnectNotification Deserialize(Stream stream, DisconnectNotification instance, long limit)
 {
     while (true)
     {
         if (limit < (long)0 || stream.Position < limit)
         {
             int num = stream.ReadByte();
             if (num == -1)
             {
                 if (limit >= (long)0)
                 {
                     throw new EndOfStreamException();
                 }
                 break;
             }
             else if (num == 8)
             {
                 instance.ErrorCode = ProtocolParser.ReadUInt32(stream);
             }
             else if (num == 18)
             {
                 instance.Reason = ProtocolParser.ReadString(stream);
             }
             else
             {
                 Key key = ProtocolParser.ReadKey((byte)num, stream);
                 if (key.Field == 0)
                 {
                     throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                 }
                 ProtocolParser.SkipKey(stream, key);
             }
         }
         else
         {
             if (stream.Position != limit)
             {
                 throw new ProtocolBufferException("Read past max limit");
             }
             break;
         }
     }
     return(instance);
 }
 public static DisconnectNotification Deserialize(Stream stream, DisconnectNotification instance)
 {
     return(DisconnectNotification.Deserialize(stream, instance, -1L));
 }
 public void Deserialize(Stream stream)
 {
     DisconnectNotification.Deserialize(stream, this);
 }
        public override bool Equals(object obj)
        {
            DisconnectNotification disconnectNotification = obj as DisconnectNotification;

            return(disconnectNotification != null && this.ErrorCode.Equals(disconnectNotification.ErrorCode) && this.HasReason == disconnectNotification.HasReason && (!this.HasReason || this.Reason.Equals(disconnectNotification.Reason)));
        }