Beispiel #1
0
        public byte[] Encode <T>(T obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("The object to be serialized cannot be null.");
            }

            var raw = ProtocolBuffersConvert.SerializeObject <T>(obj);

            if (CompressionEnabled)
            {
                return(GZipCompression.Compress(raw));
            }
            else
            {
                return(raw);
            }
        }
Beispiel #2
0
        public byte[] EncodeMessage(object message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("The message which is to be serialized cannot be null.");
            }

            var raw = ProtocolBuffersConvert.SerializeObject(message);

            if (CompressionEnabled)
            {
                return(GZipCompression.Compress(raw));
            }
            else
            {
                return(raw);
            }
        }