-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathBundleInitializer.cs
46 lines (40 loc) · 1.47 KB
/
BundleInitializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Reflection;
using static SQLitePCL.raw;
namespace Microsoft.Data.Sqlite.Utilities
{
internal static class BundleInitializer
{
private const int SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1;
private const int SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2;
public static void Initialize()
{
Assembly? assembly = null;
try
{
assembly = Assembly.Load(new AssemblyName("SQLitePCLRaw.batteries_v2"));
}
catch
{
}
if (assembly != null)
{
assembly.GetType("SQLitePCL.Batteries_V2", throwOnError: true)!.GetMethod("Init", Type.EmptyTypes)!
.Invoke(null, null);
}
if (ApplicationDataHelper.CurrentApplicationData != null)
{
var rc = sqlite3_win32_set_directory(
SQLITE_WIN32_DATA_DIRECTORY_TYPE,
ApplicationDataHelper.LocalFolderPath);
SqliteException.ThrowExceptionForRC(rc, db: null);
rc = sqlite3_win32_set_directory(
SQLITE_WIN32_TEMP_DIRECTORY_TYPE,
ApplicationDataHelper.TemporaryFolderPath);
SqliteException.ThrowExceptionForRC(rc, db: null);
}
}
}
}