Beispiel #1
0
 protected override void LoadBin(Stream s)
 {
     using (var r = new BinaryReader(s))
     {
         var tmp = r.ReadByte();
         try
         {
             Int = (FileTransferInterruption)tmp;
         }
         catch (FormatException)
         {
             throw new MessageLoadException("Invalid int: " + tmp);
         }
         var sid = r.ReadString();
         try
         {
             SessionId = FileTransferId.Parse(sid);
         }
         catch (FormatException)
         {
             throw new MessageLoadException("Invalid sid: " + sid);
         }
         Token = r.ReadUInt64();
     }
 }
Beispiel #2
0
 protected override void LoadJson(Stream s)
 {
     using (var r = new JsonStreamReader(s))
     {
         var obj = JObject.Load(r);
         var tmp = obj.GetInt32("int");
         try
         {
             Int = (FileTransferInterruption)tmp;
         }
         catch (FormatException)
         {
             throw new MessageLoadException("Invalid int: " + tmp);
         }
         var sid = obj.GetString("sid");
         try
         {
             SessionId = FileTransferId.Parse(sid);
         }
         catch (FormatException)
         {
             throw new MessageLoadException("Invalid sid: " + tmp);
         }
         var token = obj.GetString("token");
         try
         {
             Token = UInt64.Parse(token);
         }
         catch (FormatException)
         {
             throw new MessageLoadException("Invalid token: " + token);
         }
     }
 }
Beispiel #3
0
        public void SaveLoadCsFileTransferInterruption()
        {
            // arrange
            const FileTransferInterruption refInt = FileTransferInterruption.Cancel;
            var         refSid   = new FileTransferId(81289);
            const ulong refToken = 120982;
            var         msg      = new CsFileTransferInterruption
            {
                Int       = refInt,
                SessionId = refSid,
                Token     = refToken,
            };

            // act
            MultiprotocolSaveLoad(msg, () =>
            {
                // assert
                Assert.AreEqual(msg.Int, refInt);
                Assert.AreEqual(msg.SessionId, refSid);
                Assert.AreEqual(msg.Token, refToken);
            });
        }