public byte[] EncodeMessage <T>(T message) { if (message == null) { throw new ArgumentNullException("The message which is to be serialized cannot be null."); } var raw = ProtocolBuffersConvert.SerializeObject <T>(message); if (CompressionEnabled) { return(GZipCompression.Compress(raw)); } else { return(raw); } }
public object Decode(Type type, byte[] data, int offset, int count) { if (type == null) { throw new ArgumentNullException("The type to be deserialized cannot be null."); } if (data == null) { throw new ArgumentNullException("The data to be deserialized cannot be null."); } if (CompressionEnabled) { return(ProtocolBuffersConvert.DeserializeObject(type, GZipCompression.Decompress(data, offset, count))); } else { return(ProtocolBuffersConvert.DeserializeObject(type, data, offset, count)); } }