System.Data.SQLite

Check-in [f74fb3a059]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add support for the 'TypeName_SQLiteProviderServices' environment variable, which may be used to override the DbProviderServices implementation returned by the System.Data.SQLite assembly.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | ef6
Files: files | file ages | folders
SHA1: f74fb3a0599aafda387f1f317de633393677de8c
User & Date: mistachkin 2014-01-13 01:19:14.518
Context
2014-01-13
01:51
Add the testef6 binaries to the test automation setup batch file. check-in: ac75215581 user: mistachkin tags: ef6
01:19
Add support for the 'TypeName_SQLiteProviderServices' environment variable, which may be used to override the DbProviderServices implementation returned by the System.Data.SQLite assembly. check-in: f74fb3a059 user: mistachkin tags: ef6
01:17
Update version history docs. check-in: 3a4aaf4f5b user: mistachkin tags: ef6
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/environment.html.
149
150
151
152
153
154
155







156
157
158
159
160
161
162
          <td>PROCESSOR_ARCHITECTURE</td>
          <td>This environment variable is normally set by the operating
          system itself and should reflect the native processor architecture
          of the current process (e.g. a 32-bit x86 application running on a
          64-bit x64 operating system should have the value &quot;x86&quot;).
          </td>
        </tr>







      </table>
      <hr/>
      <div id="footer">
        <p>
          <a href="mailto:sqlite-users@sqlite.org?subject=SQLite.NET%20Class%20Library%20Documentation%20Feedback:%20Environment%20Variables">
            Send comments on this topic.</a>
        </p>







>
>
>
>
>
>
>







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
          <td>PROCESSOR_ARCHITECTURE</td>
          <td>This environment variable is normally set by the operating
          system itself and should reflect the native processor architecture
          of the current process (e.g. a 32-bit x86 application running on a
          64-bit x64 operating system should have the value &quot;x86&quot;).
          </td>
        </tr>
        <tr valign="top">
          <td>TypeName_SQLiteProviderServices</td>
          <td>If this environment variable is set [to anything], it will be
          used by the System.Data.SQLite.SQLiteFactory class as the type name
          containing the System.Data.Common.DbProviderServices implementation
          that should be used.</td>
        </tr>
      </table>
      <hr/>
      <div id="footer">
        <p>
          <a href="mailto:sqlite-users@sqlite.org?subject=SQLite.NET%20Class%20Library%20Documentation%20Feedback:%20Environment%20Variables">
            Send comments on this topic.</a>
        </p>
Changes to System.Data.SQLite/LINQ/SQLiteFactory_Linq.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
/********************************************************
 * ADO.NET 2.0 Data Provider for SQLite Version 3.X
 * Written by Robert Simpson (robert@blackcastlesoft.com)
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Globalization;
  using System.Reflection;
  using System.Security.Permissions;

  /// <summary>
  /// SQLite implementation of <see cref="IServiceProvider" />.
  /// </summary>
  public sealed partial class SQLiteFactory : IServiceProvider
  {

















    private static Type _dbProviderServicesType;
    private static object _sqliteServices;

    static SQLiteFactory()
    {
#if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY
        UnsafeNativeMethods.Initialize();



|















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
/********************************************************
 * ADO.NET 2.0 Data Provider for SQLite Version 3.X
 * Written by Robert Simpson (robert@blackcastlesoft.com)
 *
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Globalization;
  using System.Reflection;
  using System.Security.Permissions;

  /// <summary>
  /// SQLite implementation of <see cref="IServiceProvider" />.
  /// </summary>
  public sealed partial class SQLiteFactory : IServiceProvider
  {
    //
    // TODO: This points to the legacy "System.Data.SQLite.Linq" assembly
    //       (i.e. the one that does not support Entity Framework 6).
    //       Currently, this class and its containing assembly (i.e.
    //       "System.Data.SQLite") know nothing about the Entity Framework
    //       6 compatible assembly (i.e. "System.Data.SQLite.EF6").  This
    //       situation may need to change.
    //
    private static readonly string DefaultTypeName =
      "System.Data.SQLite.Linq.SQLiteProviderServices, System.Data.SQLite.Linq, " +
      "Version={0}, Culture=neutral, PublicKeyToken=db937bc2d44ff139";

    private static readonly BindingFlags DefaultBindingFlags =
        BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;

    ///////////////////////////////////////////////////////////////////////////

    private static Type _dbProviderServicesType;
    private static object _sqliteServices;

    static SQLiteFactory()
    {
#if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY
        UnsafeNativeMethods.Initialize();
62
63
64
65
66
67
68



69
70












71
72
73
74



75
76
77
78
79
80
81
    }

    [ReflectionPermission(SecurityAction.Assert, MemberAccess = true)]
    private object GetSQLiteProviderServicesInstance()
    {
        if (_sqliteServices == null)
        {



            Version version = this.GetType().Assembly.GetName().Version;
            Type type = Type.GetType(String.Format(CultureInfo.InvariantCulture, "System.Data.SQLite.Linq.SQLiteProviderServices, System.Data.SQLite.Linq, Version={0}, Culture=neutral, PublicKeyToken=db937bc2d44ff139", version), false);













            if (type != null)
            {
                FieldInfo field = type.GetField("Instance", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);



                _sqliteServices = field.GetValue(null);
            }
        }
        return _sqliteServices;
    }
  }
}







>
>
>

|
>
>
>
>
>
>
>
>
>
>
>
>



|
>
>
>
|






79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    }

    [ReflectionPermission(SecurityAction.Assert, MemberAccess = true)]
    private object GetSQLiteProviderServicesInstance()
    {
        if (_sqliteServices == null)
        {
            string typeName = UnsafeNativeMethods.GetSettingValue(
                "TypeName_SQLiteProviderServices", null);

            Version version = this.GetType().Assembly.GetName().Version;

            if (typeName != null)
            {
                typeName = String.Format(
                    CultureInfo.InvariantCulture, typeName, version);
            }
            else
            {
                typeName = String.Format(
                    CultureInfo.InvariantCulture, DefaultTypeName, version);
            }

            Type type = Type.GetType(typeName, false);

            if (type != null)
            {
                FieldInfo field = type.GetField(
                    "Instance", DefaultBindingFlags);

                if (field != null)
                    _sqliteServices = field.GetValue(null);
            }
        }
        return _sqliteServices;
    }
  }
}