public static byte[] ToArray(this IStorage storage) { if (storage == null) { return(new byte[0]); } var arr = new byte[storage.GetSize()]; storage.CopyTo(new MemoryStorage(arr)); return(arr); }