System.Data.SQLite

Check-in [9ae2337497]
Login

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

Overview
Comment:Code cleanup and documentation
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 9ae23374976d092b6e6aadcc8133cc31619b513d
User & Date: rmsimpson 2006-02-26 07:49:32.000
Context
2006-02-26
07:52
no message check-in: 08a1efa56a user: rmsimpson tags: sourceforge
07:49
Code cleanup and documentation check-in: 9ae2337497 user: rmsimpson tags: sourceforge
2006-02-25
17:10
Finally some toolbox icons check-in: 39050c87c5 user: rmsimpson tags: sourceforge
Changes
Unified Diff Ignore Whitespace Patch
Changes to SQLite.Designer/SQLiteAdapterDesigner.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
47
48



49
50
51
52
53
54
55
56
57
58




59
60
61
62
63
64
65







namespace SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Data.Common;
  using System.Collections;
  using System.Reflection;







  internal sealed class SQLiteAdapterDesigner : ComponentDesigner, IExtenderProvider
  {
    private ComponentDesigner _designer = null;




    public SQLiteAdapterDesigner()
    {
    }






    public override void Initialize(IComponent component)
    {
      base.Initialize(component);


      if (SQLiteDataAdapterToolboxItem._vsdesigner != null)
      {
        Type type = SQLiteDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner");
        if (type != null)
        {
          _designer = (ComponentDesigner)Activator.CreateInstance(type);
          _designer.Initialize(component);
        }
      }
    }

    protected override void Dispose(bool disposing)
    {
      if (_designer != null)
        ((IDisposable)_designer).Dispose();

      base.Dispose(disposing);
    }




    public override DesignerVerbCollection Verbs
    {
      get
      {
        return (_designer != null) ? _designer.Verbs : null;
      }
    }




    public override ICollection AssociatedComponents
    {
      get
      {
        return (_designer != null) ? _designer.AssociatedComponents : null;
      }
    }

    #region IExtenderProvider Members





    public bool CanExtend(object extendee)
    {
      return (extendee is DbDataAdapter);
    }

    #endregion
  }
>
>
>
>
>
>
>









>
>
>
>
>
>




>
>
>




>
>
>
>
>




>













|





>
>
>








>
>
>









|
>
>
>
>







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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/********************************************************
 * 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 SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Data.Common;
  using System.Collections;
  using System.Reflection;

  /// <summary>
  /// The purpose of this class is to provide context menus and event support when designing a 
  /// SQLite DataSet.  Most of the functionality is implemented by MS's VSDesigner object which we
  /// instantiate through reflection since I don't really have a design-time reference to the object
  /// and many of the objects in VSDesigner are internal.
  /// </summary>
  internal sealed class SQLiteAdapterDesigner : ComponentDesigner, IExtenderProvider
  {
    private ComponentDesigner _designer = null;

    /// <summary>
    /// Empty constructor
    /// </summary>
    public SQLiteAdapterDesigner()
    {
    }

    /// <summary>
    /// Initialize the designer by creating a SqlDataAdapterDesigner and delegating most of our
    /// functionality to it.
    /// </summary>
    /// <param name="component"></param>
    public override void Initialize(IComponent component)
    {
      base.Initialize(component);

      // Initialize a SqlDataAdapterDesigner through reflection and set it up to work on our behalf
      if (SQLiteDataAdapterToolboxItem._vsdesigner != null)
      {
        Type type = SQLiteDataAdapterToolboxItem._vsdesigner.GetType("Microsoft.VSDesigner.Data.VS.SqlDataAdapterDesigner");
        if (type != null)
        {
          _designer = (ComponentDesigner)Activator.CreateInstance(type);
          _designer.Initialize(component);
        }
      }
    }

    protected override void Dispose(bool disposing)
    {
      if (_designer != null && disposing)
        ((IDisposable)_designer).Dispose();

      base.Dispose(disposing);
    }

    /// <summary>
    /// Forwards to the SqlDataAdapterDesigner object
    /// </summary>
    public override DesignerVerbCollection Verbs
    {
      get
      {
        return (_designer != null) ? _designer.Verbs : null;
      }
    }

    /// <summary>
    /// Forwards to the SqlDataAdapterDesigner object
    /// </summary>
    public override ICollection AssociatedComponents
    {
      get
      {
        return (_designer != null) ? _designer.AssociatedComponents : null;
      }
    }

    #region IExtenderProvider Members
    /// <summary>
    /// We extend support for DbDataAdapter-derived objects
    /// </summary>
    /// <param name="extendee">The object wanting to be extended</param>
    /// <returns>Whether or not we extend that object</returns>
    public bool CanExtend(object extendee)
    {
      return (extendee is DbDataAdapter);
    }

    #endregion
  }
Changes to SQLite.Designer/SQLiteCommandDesigner.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
47







namespace SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Data.Common;
  using System.Data;






  [ProvideProperty("CommandDesignTimeVisible", typeof(IDbCommand))]
  internal sealed class SQLiteCommandDesigner : ComponentDesigner, IExtenderProvider
  {
    public SQLiteCommandDesigner()
    {
    }





    public override void Initialize(IComponent component)
    {
      base.Initialize(component);
    }





    protected override void PreFilterAttributes(System.Collections.IDictionary attributes)
    {
      base.PreFilterAttributes(attributes);
      DesignTimeVisibleAttribute att = new DesignTimeVisibleAttribute(((DbCommand)Component).DesignTimeVisible);
      attributes[att.TypeId] = att;
    }






    [Browsable(false), DesignOnly(true), DefaultValue(true)]
    public bool GetCommandDesignTimeVisible(IDbCommand command)
    {
      return ((DbCommand)command).DesignTimeVisible;
    }






    public void SetCommandDesignTimeVisible(IDbCommand command, bool visible)
    {
      ((DbCommand)command).DesignTimeVisible = visible;
    }

    #region IExtenderProvider Members






    public bool CanExtend(object extendee)
    {
      return (extendee is DbCommand);
    }

    #endregion
  }
>
>
>
>
>
>
>








>
>
>
>
>







>
>
>
>





>
>
>
>







>
>
>
>
>






>
>
>
>
>







>
>
>
>
>







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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/********************************************************
 * 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 SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Data.Common;
  using System.Data;

  /// <summary>
  /// This object provides a designer for a SQLiteCommand.  The reason we provide an additional
  /// CommandDesignTimeVisible property is because certain MS designer components will look for it and
  /// fail if its not there.
  /// </summary>
  [ProvideProperty("CommandDesignTimeVisible", typeof(IDbCommand))]
  internal sealed class SQLiteCommandDesigner : ComponentDesigner, IExtenderProvider
  {
    public SQLiteCommandDesigner()
    {
    }

    /// <summary>
    /// Initialize the instance with the given SQLiteCommand component
    /// </summary>
    /// <param name="component"></param>
    public override void Initialize(IComponent component)
    {
      base.Initialize(component);
    }

    /// <summary>
    /// Add our designtimevisible attribute to the attributes for the item
    /// </summary>
    /// <param name="attributes"></param>
    protected override void PreFilterAttributes(System.Collections.IDictionary attributes)
    {
      base.PreFilterAttributes(attributes);
      DesignTimeVisibleAttribute att = new DesignTimeVisibleAttribute(((DbCommand)Component).DesignTimeVisible);
      attributes[att.TypeId] = att;
    }

    /// <summary>
    /// Provide a get method for the CommandDesignTimeVisible provided property
    /// </summary>
    /// <param name="command">The SQLiteCommand we're designing for</param>
    /// <returns>True or false if the object is visible in design mode</returns>
    [Browsable(false), DesignOnly(true), DefaultValue(true)]
    public bool GetCommandDesignTimeVisible(IDbCommand command)
    {
      return ((DbCommand)command).DesignTimeVisible;
    }

    /// <summary>
    /// Provide a set method for our supplied CommandDesignTimeVisible property
    /// </summary>
    /// <param name="command">The SQLiteCommand to set</param>
    /// <param name="visible">The new designtime visible property to assign to the command</param>
    public void SetCommandDesignTimeVisible(IDbCommand command, bool visible)
    {
      ((DbCommand)command).DesignTimeVisible = visible;
    }

    #region IExtenderProvider Members

    /// <summary>
    /// We extend any DbCommand
    /// </summary>
    /// <param name="extendee">The object being tested</param>
    /// <returns>True if the object derives from DbCommand</returns>
    public bool CanExtend(object extendee)
    {
      return (extendee is DbCommand);
    }

    #endregion
  }
Changes to SQLite.Designer/SQLiteCommandHandler.cs.







1
2
3
4
5
6
7







namespace SQLite.Designer
{
  using System;
  using Microsoft.VisualStudio.Data;
  using System.Windows.Forms.Design;
  using Microsoft.VisualStudio.Shell.Interop;
  using Microsoft.VisualStudio;
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/********************************************************
 * 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 SQLite.Designer
{
  using System;
  using Microsoft.VisualStudio.Data;
  using System.Windows.Forms.Design;
  using Microsoft.VisualStudio.Shell.Interop;
  using Microsoft.VisualStudio;
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  }

  internal sealed class SQLiteCommandHandler : DataViewCommandHandler
  {
    private static readonly Guid guidDataCmdSet = new Guid("501822E1-B5AF-11d0-B4DC-00A0C91506EF");
    private static readonly Guid guidSQLiteCmdSet = new Guid("814658EE-A28E-4b97-BC33-4B1BC81EBECB");
    private static readonly Guid guidIFCmdId = new Guid("{74d21311-2aee-11d1-8bfb-00a0c90f26f7}");

    // 5efc7975-14bc-11cf-9b2b-00aa00573819
    // 0x5efc7975, 0x14bc, 0x11cf, { 0x9b, 0x2b, 0x00, 0xaa, 0x00, 0x57, 0x38, 0x19 }

    public SQLiteCommandHandler()
    {
    }

    public override OleCommandStatus GetCommandStatus(int[] itemIds, OleCommand command, OleCommandTextType textType, OleCommandStatus status)
    {
      if (command.GroupGuid == guidSQLiteCmdSet)







|
<
<
<







23
24
25
26
27
28
29
30



31
32
33
34
35
36
37
  }

  internal sealed class SQLiteCommandHandler : DataViewCommandHandler
  {
    private static readonly Guid guidDataCmdSet = new Guid("501822E1-B5AF-11d0-B4DC-00A0C91506EF");
    private static readonly Guid guidSQLiteCmdSet = new Guid("814658EE-A28E-4b97-BC33-4B1BC81EBECB");
    private static readonly Guid guidIFCmdId = new Guid("{74d21311-2aee-11d1-8bfb-00a0c90f26f7}");
   



    public SQLiteCommandHandler()
    {
    }

    public override OleCommandStatus GetCommandStatus(int[] itemIds, OleCommand command, OleCommandTextType textType, OleCommandStatus status)
    {
      if (command.GroupGuid == guidSQLiteCmdSet)
186
187
188
189
190
191
192

193
194
195
196
197
198
199
        returnValue = base.ExecuteCommand(itemId, command, executionOption, arguments);
      }
      return returnValue;
    }

    private void CreateTable()
    {

    }

    private void DropSelectedTables()
    {
      int[] items = DataViewHierarchyAccessor.GetSelectedItems();
      int n;
      object[] parts;







>







190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
        returnValue = base.ExecuteCommand(itemId, command, executionOption, arguments);
      }
      return returnValue;
    }

    private void CreateTable()
    {
      // TODO: Implement this command
    }

    private void DropSelectedTables()
    {
      int[] items = DataViewHierarchyAccessor.GetSelectedItems();
      int n;
      object[] parts;
261
262
263
264
265
266
267

268
269
270
271
272
273
274
275
276
277
278
279
280
    private void Vacuum()
    {
      DataViewHierarchyAccessor.Connection.Command.ExecuteWithoutResults("VACUUM", (int)System.Data.CommandType.Text, null, 0);
    }

    private void ChangePassword()
    {

     // System.Data.SQLite.SQLiteConnection cnn = DataViewHierarchyAccessor.Connection.ConnectionSupport.ProviderObject as System.Data.SQLite.SQLiteConnection;
     // if (cnn == null) return;
    }

    private void Refresh(int itemId)
    {
      IVsUIHierarchy hier = DataViewHierarchyAccessor.Hierarchy as IVsUIHierarchy;

      Guid g = VSConstants.GUID_VSStandardCommandSet97;
      hier.ExecCommand((uint)itemId, ref g, (uint)0xbd, (uint)OleCommandExecutionOption.DoDefault, IntPtr.Zero, IntPtr.Zero);
    }
  }
}







>













266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
    private void Vacuum()
    {
      DataViewHierarchyAccessor.Connection.Command.ExecuteWithoutResults("VACUUM", (int)System.Data.CommandType.Text, null, 0);
    }

    private void ChangePassword()
    {
      // TODO: Implement this command, but we have to use reflection because we don't have a design-time reference to the SQLite object
     // System.Data.SQLite.SQLiteConnection cnn = DataViewHierarchyAccessor.Connection.ConnectionSupport.ProviderObject as System.Data.SQLite.SQLiteConnection;
     // if (cnn == null) return;
    }

    private void Refresh(int itemId)
    {
      IVsUIHierarchy hier = DataViewHierarchyAccessor.Hierarchy as IVsUIHierarchy;

      Guid g = VSConstants.GUID_VSStandardCommandSet97;
      hier.ExecCommand((uint)itemId, ref g, (uint)0xbd, (uint)OleCommandExecutionOption.DoDefault, IntPtr.Zero, IntPtr.Zero);
    }
  }
}
Changes to SQLite.Designer/SQLiteConnectionProperties.cs.
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78



79



80






81

82

















83
84
namespace SQLite.Designer
{
  using System;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.VisualStudio.Data;
  using Microsoft.Win32;

  internal class SQLiteConnectionProperties : AdoDotNetConnectionProperties
  {
    private static System.Reflection.Assembly _sqlite = null;

    static SQLiteConnectionProperties()
    {
      AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    }

    private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
      if (args.Name.StartsWith("System.Data.SQLite", StringComparison.InvariantCultureIgnoreCase))
      {
        return SQLiteAssembly;
      }
      return null;
    }

    internal static System.Reflection.Assembly SQLiteAssembly
    {
      get
      {
        if (_sqlite == null)
        {
          using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\.NETFramework\\v2.0.50727\\AssemblyFoldersEx\\SQLite"))
          {
            if (key != null)
            {
              _sqlite = System.Reflection.Assembly.LoadFrom(System.IO.Path.Combine(key.GetValue(null).ToString(), "System.Data.SQLite.DLL"));
            }
          }
        }
        return _sqlite;
      }
    }

    public SQLiteConnectionProperties() : base("System.Data.SQLite")
    {
    }

    public SQLiteConnectionProperties(string connectionString) : base("System.Data.SQLite", connectionString)
    {
    }

    public override string[] GetBasicProperties()
    {
      return new string[] { "Data Source" };
    }

    public override bool  IsComplete
    {
      get 
      {
        return true;
        //if (!(this["Data Source"] is string) ||
        //  (this["Data Source"] as string).Length == 0)
        //{
        //  return false;
        //}

        //return true;
      }
    }




    public override bool EquivalentTo(DataConnectionProperties connectionProperties)



    {






      return base.EquivalentTo(connectionProperties);

    }

















  }
}







<
<
<
|
<
<
<
<
|
<
<
<
<
<
<
<
<
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















<
<
<
<
<
|
<
|
|
|
>
>
>
|
>
>
>
|
>
>
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace SQLite.Designer
{
  using System;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.VisualStudio.Data;
  using Microsoft.Win32;




  /// <summary>




  /// Provides rudimentary connectionproperties support








  /// </summary>
  internal sealed class SQLiteConnectionProperties : AdoDotNetConnectionProperties
  {
















    public SQLiteConnectionProperties() : base("System.Data.SQLite")
    {
    }

    public SQLiteConnectionProperties(string connectionString) : base("System.Data.SQLite", connectionString)
    {
    }

    public override string[] GetBasicProperties()
    {
      return new string[] { "Data Source" };
    }

    public override bool  IsComplete
    {
      get 
      {
        return true;





      }

    }

    // Provides automatic locating and loading of the SQLite assembly if its not registered in the GAC.
    // However, if it's not registered in the GAC, then certain design-time elements will fail.
    //
    //private static System.Reflection.Assembly _sqlite = null;
    //static SQLiteConnectionProperties()
    //{
    //  AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    //}

    //private static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    //{
    //  if (args.Name.StartsWith("System.Data.SQLite", StringComparison.InvariantCultureIgnoreCase))
    //  {
    //    return SQLiteAssembly;
    //  }
    //  return null;
    //}

    //internal static System.Reflection.Assembly SQLiteAssembly
    //{
    //  get
    //  {
    //    if (_sqlite == null)
    //    {
    //      using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\.NETFramework\\v2.0.50727\\AssemblyFoldersEx\\SQLite"))
    //      {
    //        if (key != null)
    //        {
    //          _sqlite = System.Reflection.Assembly.LoadFrom(System.IO.Path.Combine(key.GetValue(null).ToString(), "System.Data.SQLite.DLL"));
    //        }
    //      }
    //    }
    //    return _sqlite;
    //  }
    //}
  }
}
Changes to SQLite.Designer/SQLiteConnectionStringEditor.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







namespace SQLite.Designer
{
  using System;
  using System.Reflection;
  using System.Data;
  using System.Data.Common;
  using System.ComponentModel.Design;
  using System.ComponentModel;









  internal sealed class SQLiteConnectionStringEditor : ObjectSelectorEditor
  {
    private ObjectSelectorEditor.Selector _selector = null;

    private Type _managerType = null;

    public SQLiteConnectionStringEditor()
    {
      Assembly assm = Assembly.Load("Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
      if (assm != null)
      {
        _managerType = assm.GetType("Microsoft.VSDesigner.Data.VS.VsConnectionManager");
      }
    }





    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
      if (provider == null || context == null) return value;
      if (context.Instance == null) return value;

      try
>
>
>
>
>
>
>









>
>
>
>
>
>
>
>




|

|

|





>
>
>
>







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
47
48
49
/********************************************************
 * 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 SQLite.Designer
{
  using System;
  using System.Reflection;
  using System.Data;
  using System.Data.Common;
  using System.ComponentModel.Design;
  using System.ComponentModel;

  /// <summary>
  /// This class provides connectionstring editing support in the properties window when
  /// using a SQLiteConnection as a toolbox component on a form (for example).
  /// 
  /// In order to provide the dropdown list, unless someone knows a better way, I have to use
  /// the internal VsConnectionManager class since it utilizes some interfaces in the designer
  /// that are internal to the VSDesigner object.  We instantiate it and utilize it through reflection.
  /// </summary>
  internal sealed class SQLiteConnectionStringEditor : ObjectSelectorEditor
  {
    private ObjectSelectorEditor.Selector _selector = null;

    private static Type _managerType = null;

    static SQLiteConnectionStringEditor()
    {
      Assembly assm = SQLiteDataAdapterToolboxItem._vsdesigner;
      if (assm != null)
      {
        _managerType = assm.GetType("Microsoft.VSDesigner.Data.VS.VsConnectionManager");
      }
    }

    public SQLiteConnectionStringEditor()
    {
    }

    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
      if (provider == null || context == null) return value;
      if (context.Instance == null) return value;

      try
Changes to SQLite.Designer/SQLiteConnectionUIControl.cs.
13
14
15
16
17
18
19



20
21
22
23
24
25
26
  using System.Data;
  using System.Drawing;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.VisualStudio.Data;
  using Microsoft.Win32;




  [ToolboxItem(false)]
  public partial class SQLiteConnectionUIControl : DataConnectionUIControl
  {
    public SQLiteConnectionUIControl()
    {
      InitializeComponent();
    }







>
>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  using System.Data;
  using System.Drawing;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.VisualStudio.Data;
  using Microsoft.Win32;

  /// <summary>
  /// Provides a UI to edit/create SQLite database connections
  /// </summary>
  [ToolboxItem(false)]
  public partial class SQLiteConnectionUIControl : DataConnectionUIControl
  {
    public SQLiteConnectionUIControl()
    {
      InitializeComponent();
    }
Changes to SQLite.Designer/SQLiteDataAdapterToolboxItem.cs.







1
2
3
4
5
6
7
8
9
10
11
12
13









14
15
16
17
18
19
20







namespace SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Drawing.Design;
  using System.Data.Common;
  using System.Reflection;
  using System.Collections.Generic;
  using System.Windows.Forms;
  using System.Drawing;
  using System.Runtime.Serialization;










  [Serializable]
  [ToolboxItem(typeof(SQLiteDataAdapterToolboxItem))]
  internal sealed class SQLiteDataAdapterToolboxItem : ToolboxItem
  {
    private static Type _wizard = null;
    
    internal static Assembly _vsdesigner = null;
>
>
>
>
>
>
>













>
>
>
>
>
>
>
>
>







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
/********************************************************
 * 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 SQLite.Designer
{
  using System;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Drawing.Design;
  using System.Data.Common;
  using System.Reflection;
  using System.Collections.Generic;
  using System.Windows.Forms;
  using System.Drawing;
  using System.Runtime.Serialization;

  /// <summary>
  /// Provides a toolboxitem for a SQLiteDataAdapter.  This is required in order for us to 
  /// pop up the connection wizard when you drop the tool on a form, and to create the hidden commands
  /// that are assigned to the data adapter and keep them hidden.  The hiding at runtime of the controls
  /// is accomplished both here during the creation of the components and in the SQLiteCommandDesigner
  /// which provides properties to hide the objects when they're supposed to be hidden.
  /// 
  /// The connection wizard is instantiated in the VSDesigner through reflection.
  /// </summary>
  [Serializable]
  [ToolboxItem(typeof(SQLiteDataAdapterToolboxItem))]
  internal sealed class SQLiteDataAdapterToolboxItem : ToolboxItem
  {
    private static Type _wizard = null;
    
    internal static Assembly _vsdesigner = null;
28
29
30
31
32
33
34

35
36
37
38
39
40
41





42
43
44
45
46
47
48
    public SQLiteDataAdapterToolboxItem(Type type) : this(type, (Bitmap)null)
    {
    }

    public SQLiteDataAdapterToolboxItem(Type type, Bitmap bmp) : base(type)
    {
      DisplayName = "SQLiteDataAdapter";

    }

    private SQLiteDataAdapterToolboxItem(SerializationInfo info, StreamingContext context)
    {
      Deserialize(info, context);
    }






    protected override IComponent[] CreateComponentsCore(IDesignerHost host)
    {
      DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite");

      DbDataAdapter dataAdapter = fact.CreateDataAdapter();
      IContainer container = host.Container;
      







>







>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
    public SQLiteDataAdapterToolboxItem(Type type) : this(type, (Bitmap)null)
    {
    }

    public SQLiteDataAdapterToolboxItem(Type type, Bitmap bmp) : base(type)
    {
      DisplayName = "SQLiteDataAdapter";
      Bitmap = bmp;
    }

    private SQLiteDataAdapterToolboxItem(SerializationInfo info, StreamingContext context)
    {
      Deserialize(info, context);
    }

    /// <summary>
    /// Creates the necessary components associated with this data adapter instance
    /// </summary>
    /// <param name="host">The designer host</param>
    /// <returns>The components created by this toolbox item</returns>
    protected override IComponent[] CreateComponentsCore(IDesignerHost host)
    {
      DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite");

      DbDataAdapter dataAdapter = fact.CreateDataAdapter();
      IContainer container = host.Container;
      
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91






92
93
94
95
96
97
98
      }

      container.Add(dataAdapter);

      List<IComponent> list = new List<IComponent>();
      list.Add(dataAdapter);


      if (_wizard != null)
      {
        using (Form wizard = (Form)Activator.CreateInstance(_wizard, new object[] { host, dataAdapter }))
        {
          wizard.ShowDialog();
        }
      }

      if (dataAdapter.SelectCommand != null) list.Add(dataAdapter.SelectCommand);
      if (dataAdapter.InsertCommand != null) list.Add(dataAdapter.InsertCommand);
      if (dataAdapter.DeleteCommand != null) list.Add(dataAdapter.DeleteCommand);
      if (dataAdapter.UpdateCommand != null) list.Add(dataAdapter.UpdateCommand);

      return list.ToArray();      
    }







    private static string GenerateName(IContainer container, string baseName)
    {
      ComponentCollection coll = container.Components;
      string uniqueName;
      int n = 1;
      do
      {







>
















>
>
>
>
>
>







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
117
118
119
120
121
122
123
124
125
126
127
      }

      container.Add(dataAdapter);

      List<IComponent> list = new List<IComponent>();
      list.Add(dataAdapter);

      // Show the connection wizard if we have a type for it
      if (_wizard != null)
      {
        using (Form wizard = (Form)Activator.CreateInstance(_wizard, new object[] { host, dataAdapter }))
        {
          wizard.ShowDialog();
        }
      }

      if (dataAdapter.SelectCommand != null) list.Add(dataAdapter.SelectCommand);
      if (dataAdapter.InsertCommand != null) list.Add(dataAdapter.InsertCommand);
      if (dataAdapter.DeleteCommand != null) list.Add(dataAdapter.DeleteCommand);
      if (dataAdapter.UpdateCommand != null) list.Add(dataAdapter.UpdateCommand);

      return list.ToArray();      
    }

    /// <summary>
    /// Generates a unique name for the given object
    /// </summary>
    /// <param name="container">The container where we're being instantiated</param>
    /// <param name="baseName">The core name of the object to create a unique instance of</param>
    /// <returns>A unique name within the given container</returns>
    private static string GenerateName(IContainer container, string baseName)
    {
      ComponentCollection coll = container.Components;
      string uniqueName;
      int n = 1;
      do
      {
Changes to SQLite.Designer/SQLiteDataConnectionSupport.cs.
11
12
13
14
15
16
17



18
19
20
21
22
23
24
25
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.Win32;




  internal class SQLiteDataConnectionSupport : AdoDotNetConnectionSupport
  {
    private SQLiteDataViewSupport _dataViewSupport;
    private SQLiteDataObjectSupport _dataObjectSupport;
    private SQLiteDataObjectIdentifierResolver _dataObjectIdentifierResolver;

    public SQLiteDataConnectionSupport()
      : base("System.Data.SQLite")







>
>
>
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.Win32;

  /// <summary>
  /// This class creates many of the DDEX components when asked for by the server explorer.
  /// </summary>
  internal sealed class SQLiteDataConnectionSupport : AdoDotNetConnectionSupport
  {
    private SQLiteDataViewSupport _dataViewSupport;
    private SQLiteDataObjectSupport _dataObjectSupport;
    private SQLiteDataObjectIdentifierResolver _dataObjectIdentifierResolver;

    public SQLiteDataConnectionSupport()
      : base("System.Data.SQLite")
Changes to SQLite.Designer/SQLiteDataObjectIdentifierResolver.cs.
9
10
11
12
13
14
15





16
17
18
19
20
21
22
23
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;






  internal class SQLiteDataObjectIdentifierResolver : DataObjectIdentifierResolver, IObjectWithSite
  {
    private DataConnection _connection;

    public SQLiteDataObjectIdentifierResolver()
    {
    }








>
>
>
>
>
|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;

  /// <summary>
  /// This class is used to build identifier arrays and contract them.  Typically they are 
  /// passed to SQLiteConnection.GetSchema() or are contracted for display on the screen or in the
  /// properties window.
  /// </summary>
  internal sealed class SQLiteDataObjectIdentifierResolver : DataObjectIdentifierResolver, IObjectWithSite
  {
    private DataConnection _connection;

    public SQLiteDataObjectIdentifierResolver()
    {
    }

89
90
91
92
93
94
95







96
97
98
99
100
101
102
      {
        identifier[1] = null;
      }

      return identifier;
    }








    protected override object[] QuickContractIdentifier(string typeName, object[] fullIdentifier)
    {
      if (fullIdentifier.Length < 2) return fullIdentifier;

      object[] identifier = new object[fullIdentifier.Length - 1];

      for (int n = 1; n < fullIdentifier.Length; n++)







>
>
>
>
>
>
>







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
      {
        identifier[1] = null;
      }

      return identifier;
    }

    /// <summary>
    /// Strips out the schema, which we don't really support but has to be there for certain operations internal
    /// to MS's designer implementation.
    /// </summary>
    /// <param name="typeName">The type of identifier to contract</param>
    /// <param name="fullIdentifier">The full identifier array</param>
    /// <returns>A contracted identifier array</returns>
    protected override object[] QuickContractIdentifier(string typeName, object[] fullIdentifier)
    {
      if (fullIdentifier.Length < 2) return fullIdentifier;

      object[] identifier = new object[fullIdentifier.Length - 1];

      for (int n = 1; n < fullIdentifier.Length; n++)
Changes to SQLite.Designer/SQLiteDataObjectSupport.cs.
10
11
12
13
14
15
16




17
18
19
20
21
22
23
24
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;





  internal class SQLiteDataObjectSupport : DataObjectSupport
  {
    public SQLiteDataObjectSupport()
      : base("SQLite.Designer.SQLiteDataObjectSupport", typeof(SQLiteDataObjectSupport).Assembly)
    {
    }
  }
}







>
>
>
>
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;

  /// <summary>
  /// Doesn't do much other than provide the DataObjectSupport base object with a location
  /// where the XML resource can be found.
  /// </summary>
  internal sealed class SQLiteDataObjectSupport : DataObjectSupport
  {
    public SQLiteDataObjectSupport()
      : base("SQLite.Designer.SQLiteDataObjectSupport", typeof(SQLiteDataObjectSupport).Assembly)
    {
    }
  }
}
Changes to SQLite.Designer/SQLiteDataSourceInformation.cs.
9
10
11
12
13
14
15



16
17
18
19
20
21
22
23
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.Data.AdoDotNet;




  internal class SQLiteDataSourceInformation : AdoDotNetDataSourceInformation
  {
    public SQLiteDataSourceInformation(DataConnection connection) : base(connection)
    {
      Initialize();
    }

    private void Initialize()







>
>
>
|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.Data.AdoDotNet;

  /// <summary>
  /// Provides basic DataSourceInformation about the underlying connection
  /// </summary>
  internal sealed class SQLiteDataSourceInformation : AdoDotNetDataSourceInformation
  {
    public SQLiteDataSourceInformation(DataConnection connection) : base(connection)
    {
      Initialize();
    }

    private void Initialize()
Changes to SQLite.Designer/SQLiteDataViewSupport.cs.
10
11
12
13
14
15
16



17
18
19
20
21
22
23
24
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;




  internal class SQLiteDataViewSupport : DataViewSupport
  {
    public SQLiteDataViewSupport()
      : base("SQLite.Designer.SQLiteDataViewSupport", typeof(SQLiteDataViewSupport).Assembly)
    {
    }
  }
}







>
>
>
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  using System;
  using System.Collections.Generic;
  using System.Text;
  using Microsoft.VisualStudio.Data;
  using Microsoft.VisualStudio.OLE.Interop;
  using Microsoft.VisualStudio.Data.AdoDotNet;

  /// <summary>
  /// Provides DataViewSupport with a location where the XML file is for the Server Explorer's view.
  /// </summary>
  internal sealed class SQLiteDataViewSupport : DataViewSupport
  {
    public SQLiteDataViewSupport()
      : base("SQLite.Designer.SQLiteDataViewSupport", typeof(SQLiteDataViewSupport).Assembly)
    {
    }
  }
}
Changes to SQLite.Designer/SQLitePackage.cs.
9
10
11
12
13
14
15




16
17
18
19
20
21
22
{
  using System;
  using Microsoft.VisualStudio.Shell;
  using System.Runtime.InteropServices;
  using System.ComponentModel.Design;
  using Microsoft.VisualStudio.Shell.Interop;





  [Guid("DCBE6C8D-0E57-4099-A183-98FF74C64D9C")]
  internal sealed class SQLitePackage : Package
  {
    public SQLitePackage()
    {
    }








>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  using System;
  using Microsoft.VisualStudio.Shell;
  using System.Runtime.InteropServices;
  using System.ComponentModel.Design;
  using Microsoft.VisualStudio.Shell.Interop;

  /// <summary>
  /// Ideally we'd be a package provider, but the VS Express Editions don't support us, so this class
  /// exists so that in the future we can perhaps work with the Express Editions.
  /// </summary>
  [Guid("DCBE6C8D-0E57-4099-A183-98FF74C64D9C")]
  internal sealed class SQLitePackage : Package
  {
    public SQLitePackage()
    {
    }

Changes to SQLite.Designer/SQLiteProviderObjectFactory.cs.
9
10
11
12
13
14
15



16
17
18
19
20
21
22
{
  using System;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.VisualStudio.Data;
  using System.Runtime.InteropServices;
  using Microsoft.Data.ConnectionUI;




  [Guid("DCBE6C8D-0E57-4099-A183-98FF74C64D9D")]
  internal sealed class SQLiteProviderObjectFactory : AdoDotNetProviderObjectFactory
  {
    public SQLiteProviderObjectFactory()
    {
    }








>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
  using System;
  using Microsoft.VisualStudio.Data.AdoDotNet;
  using Microsoft.VisualStudio.Data;
  using System.Runtime.InteropServices;
  using Microsoft.Data.ConnectionUI;

  /// <summary>
  /// For a package-based provider, this factory creates instances of the main objects we support
  /// </summary>
  [Guid("DCBE6C8D-0E57-4099-A183-98FF74C64D9D")]
  internal sealed class SQLiteProviderObjectFactory : AdoDotNetProviderObjectFactory
  {
    public SQLiteProviderObjectFactory()
    {
    }