Exemple #1
0
        /// <summary>
        /// Serializes the message and save the result to the message's
        /// <see cref="Msg._MsgFrame" /> property.
        /// </summary>
        /// <param name="msg">The message to be serialized.</param>
        private void Serialize(Msg msg)
        {
            var ms = new EnhancedMemoryStream(DefMsgSize);
            int cbMsg;

            cbMsg         = Msg.Save(ms, msg);
            msg._MsgFrame = router.EncryptFrame(ms.GetBuffer(), cbMsg);
        }
Exemple #2
0
        private void Verify(EnhancedMemoryStream ms, int cb)
        {
            byte[] buffer = ms.GetBuffer();

            for (int i = 0; i < cb; i++)
            {
                Assert.AreEqual((byte)i, buffer[i], string.Format("pos={0}", i));
            }
        }
Exemple #3
0
        /// <summary>
        /// Renders the instance into a string suitable for using as an HTTP cookie.
        /// </summary>
        /// <returns>The cookie string.</returns>
        public override string ToString()
        {
            using (var ms = new EnhancedMemoryStream())
            {
                ms.WriteInt16(Magic);
                ms.WriteInt64(IssueDateUtc.Ticks);
                ms.WriteBytesNoLen(ID.ToByteArray());

                return(Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length));
            }
        }