Esempio n. 1
0
        /// <summary>
        /// The unpack.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <returns>
        /// The <see cref="BaseMessage"/>.
        /// </returns>
        public static BaseMessage Unpack(byte[] data)
        {
            if (serializer == null)
            {
                serializer = MessagePackSerializer.Get <DynamicMessage>();
            }

            DynamicMessage dm = serializer.UnpackSingleObject(data);

            return(dm.DataObject);
        }
Esempio n. 2
0
        /// <summary>
        /// The pack.
        /// </summary>
        /// <param name="mb">
        /// The mb.
        /// </param>
        /// <returns>
        /// The <see cref="byte[]"/>.
        /// </returns>
        public static byte[] Pack(BaseMessage mb)
        {
            var dm = new DynamicMessage();

            dm.DataObject = mb;
            if (serializer == null)
            {
                serializer = MessagePackSerializer.Get <DynamicMessage>();
            }

            return(serializer.PackSingleObject(dm));
        }