Skip to content

Commit 7728919

Browse files
committed
Add SQLiteConnectionExtensions class with serialization methods
1 parent e28c188 commit 7728919

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Runtime/SQLiteConnectionExtensions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace SQLite
2+
{
3+
public static class SQLiteConnectionExtensions
4+
{
5+
public static byte[] Serialize(this SQLiteConnection db, string schema = null)
6+
{
7+
return SQLite3.Serialize(db.Handle, schema);
8+
}
9+
10+
public static SQLiteConnection Deserialize(this SQLiteConnection db, byte[] buffer, string schema = null, SQLite3.DeserializeFlags flags = SQLite3.DeserializeFlags.None)
11+
{
12+
return Deserialize(db, buffer, buffer.LongLength, schema, flags);
13+
}
14+
15+
public static SQLiteConnection Deserialize(this SQLiteConnection db, byte[] buffer, long usedSize, string schema = null, SQLite3.DeserializeFlags flags = SQLite3.DeserializeFlags.None)
16+
{
17+
SQLite3.Result result = SQLite3.Deserialize(db.Handle, schema, buffer, usedSize, buffer.LongLength, flags);
18+
if (result != SQLite3.Result.OK)
19+
{
20+
throw SQLiteException.New(result, SQLite3.GetErrmsg(db.Handle));
21+
}
22+
return db;
23+
}
24+
}
25+
}

Runtime/SQLiteConnectionExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)