private byte[] GetData(string id) {
var bytes = _references?.GetObject(id) as byte[];
if (bytes == null) throw new Exception("Data is missing");
var key = _references.GetObject(id + "//encrypted") as byte[];
if (key != null) {
Xor(bytes, key);
}
if (_references.GetObject(id + "//compressed/lzf") as bool? == true) {
bytes = DecompressLzfSmart(bytes);
} else if (_references.GetObject(id + "//compressed") as bool? == true) {
using (var memory = new MemoryStream(bytes))
using (var output = new MemoryStream(bytes.Length * 2)) {
using (var decomp = new DeflateStream(memory, CompressionMode.Decompress)) {
decomp.CopyTo(output);
}
bytes = output.ToArray();
}
}
return bytes;
}