Example #1
0
        /// <summary>
        /// Serializes the specified object to Thrift binary data.
        /// </summary>
        /// <typeparam name="T">The object type.</typeparam>
        /// <param name="obj">The object.</param>
        /// <returns>Thrift binary data representing the object.</returns>
        public static byte[] Serialize <T>(T obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var transport = new ThriftMemoryTransport();
            var protocol  = new ThriftBinaryProtocol(transport);

            ThriftStructWriter.Write(obj, protocol);
            return(transport.GetInternalBuffer());
        }