Datei: Provider/SqliteProvider/SqliteUISupport/SqliteUIProvider.cs

Last Commit (f4949d4)
1 using System.IO;
2 using System.Windows.Forms;
3 using NDO.UISupport;
4
5 namespace NDO.SqliteUISupport
6 {
7 ····public class SqliteUIProvider : DbUISupportBase
8 ····{
9 ········public override string Name => "Sqlite";
10
11 ········public override NdoDialogResult ShowConnectionDialog( ref string connectionString )
12 ········{
13 ············OpenFileDialog ofd = new OpenFileDialog();
14 ············if (!string.IsNullOrEmpty( connectionString ))
15 ············{
16 ················try
17 ················{
18 ····················string fileName = connectionString.Substring( connectionString.IndexOf( '=' ) + 1 );
19 ····················ofd.InitialDirectory = Path.GetDirectoryName( connectionString );
20 ················}
21 ················catch { }
22 ············}
23 ············ofd.Filter = "SQLite Database File (*.db)|*.db";
24 ············ofd.DefaultExt = ("db");
25 ············ofd.CheckFileExists = false;
26 ············DialogResult result = DialogResult.OK;
27 ············if ((result = ofd.ShowDialog()) == DialogResult.OK)
28 ············{
29 ················connectionString = "Data Source=" + ofd.FileName;
30 ············}
31 ············return (NdoDialogResult)result;
32 ········}
33
34 ········public override NdoDialogResult ShowCreateDbDialog( ref object necessaryData )
35 ········{
36 ············string connectionString = string.Empty;
37 ············NdoDialogResult result = ShowConnectionDialog( ref connectionString );
38 ············if (result == NdoDialogResult.OK)
39 ············{
40 ················necessaryData = connectionString;
41 ············}
42
43 ············return result;
44 ········}
45
46 ········public override string CreateDatabase( object necessaryData )
47 ········{
48 ············string connectionString = (string)necessaryData;
49 ············string path = connectionString.Substring( connectionString.IndexOf( '=' ) + 1 ).Trim();
50
51 return Provider. CreateDatabase( path, connectionString ) ;
52 ········}
53 ····}
54 }
55
New Commit (947ce88)
1 using System.IO;
2 using System.Windows.Forms;
3 using NDO.UISupport;
4
5 namespace NDO.SqliteUISupport
6 {
7 ····public class SqliteUIProvider : DbUISupportBase
8 ····{
9 ········public override string Name => "Sqlite";
10
11 ········public override NdoDialogResult ShowConnectionDialog( ref string connectionString )
12 ········{
13 ············OpenFileDialog ofd = new OpenFileDialog();
14 ············if (!string.IsNullOrEmpty( connectionString ))
15 ············{
16 ················try
17 ················{
18 ····················string fileName = connectionString.Substring( connectionString.IndexOf( '=' ) + 1 );
19 ····················ofd.InitialDirectory = Path.GetDirectoryName( connectionString );
20 ················}
21 ················catch { }
22 ············}
23 ············ofd.Filter = "SQLite Database File (*.db)|*.db";
24 ············ofd.DefaultExt = ("db");
25 ············ofd.CheckFileExists = false;
26 ············DialogResult result = DialogResult.OK;
27 ············if ((result = ofd.ShowDialog()) == DialogResult.OK)
28 ············{
29 ················connectionString = "Data Source=" + ofd.FileName;
30 ············}
31 ············return (NdoDialogResult)result;
32 ········}
33
34 ········public override NdoDialogResult ShowCreateDbDialog( ref object necessaryData )
35 ········{
36 ············string connectionString = string.Empty;
37 ············NdoDialogResult result = ShowConnectionDialog( ref connectionString );
38 ············if (result == NdoDialogResult.OK)
39 ············{
40 ················necessaryData = connectionString;
41 ············}
42
43 ············return result;
44 ········}
45
46 ········public override string CreateDatabase( object necessaryData )
47 ········{
48 ············string connectionString = (string)necessaryData;
49 ············string path = connectionString.Substring( connectionString.IndexOf( '=' ) + 1 ).Trim();
50
51 return EnsureProvider( ) . CreateDatabase( path, connectionString ) ;
52 ········}
53 ····}
54 }
55