public T Decode <T>(byte[] data, int offset, int count) { if (data == null) { throw new ArgumentNullException("The data to be deserialized cannot be null."); } if (CompressionEnabled) { return(ProtocolBuffersConvert.DeserializeObject <T>(GZipCompression.Decompress(data, offset, count))); } else { return(ProtocolBuffersConvert.DeserializeObject <T>(data, offset, count)); } }
public T DecodeMessage <T>(byte[] data, int dataOffset, int dataLength) { if (data == null) { throw new ArgumentNullException("The data which is to be deserialized cannot be null."); } if (CompressionEnabled) { return(ProtocolBuffersConvert.DeserializeObject <T>(GZipCompression.Decompress(data, dataOffset, dataLength))); } else { return(ProtocolBuffersConvert.DeserializeObject <T>(data, dataOffset, dataLength)); } }
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); } }
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); } }