11/*
2- Copyright 2014-2026 SourceGear, LLC
2+ Copyright 2014-2019 SourceGear, LLC
33
44 Licensed under the Apache License, Version 2.0 (the "License");
55 you may not use this file except in compliance with the License.
@@ -14,13 +14,55 @@ You may obtain a copy of the License at
1414 limitations under the License.
1515*/
1616
17+ using System ;
18+ using System . Collections . Generic ;
19+ using System . Reflection ;
20+ using System . IO ;
21+
1722namespace SQLitePCL
1823{
1924 public static class Batteries_V2
2025 {
26+ class MyGetFunctionPointer : IGetFunctionPointer
27+ {
28+ readonly IntPtr _dll ;
29+ public MyGetFunctionPointer ( IntPtr dll )
30+ {
31+ _dll = dll ;
32+ }
33+
34+ public IntPtr GetFunctionPointer ( string name )
35+ {
36+ if ( NativeLibrary . TryGetExport ( _dll , name , out var f ) )
37+ {
38+ //System.Console.WriteLine("{0}.{1} : {2}", _dll, name, f);
39+ return f ;
40+ }
41+ else
42+ {
43+ return IntPtr . Zero ;
44+ }
45+ }
46+ }
47+ static IGetFunctionPointer MakeDynamic ( string name , int flags )
48+ {
49+ // TODO should this be GetExecutingAssembly()?
50+ var assy = typeof ( SQLitePCL . raw ) . Assembly ;
51+ var dll = SQLitePCL . NativeLibrary . Load ( name , assy , flags ) ;
52+ var gf = new MyGetFunctionPointer ( dll ) ;
53+ return gf ;
54+ }
55+ static void DoDynamic_cdecl ( string name , int flags )
56+ {
57+ var gf = MakeDynamic ( name , flags ) ;
58+ SQLitePCL . SQLite3Provider_dynamic_cdecl . Setup ( name , gf ) ;
59+ SQLitePCL . raw . SetProvider ( new SQLite3Provider_dynamic_cdecl ( ) ) ;
60+ }
61+
2162 public static void Init ( )
2263 {
23- raw . SetProvider ( new SQLite3Provider_e_sqlite3 ( ) ) ;
64+ DoDynamic_cdecl ( "e_sqlite3" , NativeLibrary . WHERE_PLAIN ) ;
2465 }
2566 }
2667}
68+
0 commit comments