Datei: Provider/MySqlNdoProvider/MySqlUISupport/MySqlUIProvider.cs
Last Commit (f4949d4)
1 | using NDO.UISupport; |
2 | using System; |
3 | using System.Collections.Generic; |
4 | using System.Linq; |
5 | using System.Text; |
6 | using System.Windows.Forms; |
7 | |
8 | namespace MySqlUISupport |
9 | { |
10 | ····public class MySqlUIProvider : DbUISupportBase |
11 | ····{ |
12 | ········public override string Name => "MySql"; |
13 | |
14 | ········public override NdoDialogResult ShowCreateDbDialog( ref object necessaryData ) |
15 | ········{ |
16 | ············NDOCreateDbParameter par; |
17 | ············if (necessaryData == null) |
18 | ················par = new NDOCreateDbParameter( string.Empty, "Data Source=localhost;User Id=root;" ); |
19 | ············else |
20 | ················par = necessaryData as NDOCreateDbParameter; |
21 | ············if (par == null) |
22 | ················throw new ArgumentException( "MySql provider: parameter type " + necessaryData.GetType().FullName + " is wrong.", "necessaryData" ); |
23 | ············if (par.ConnectionString == null || par.ConnectionString == string.Empty) |
24 | ················par.ConnectionString = "Data Source=localhost;User Id=root"; |
25 | ············ConnectionDialog dlg = new ConnectionDialog( par.ConnectionString, true ); |
26 | ············if (dlg.ShowDialog() == DialogResult.Cancel) |
27 | ················return NdoDialogResult.Cancel; |
28 | ············par.ConnectionString = dlg.ConnectionString; |
29 | ············par.DatabaseName = dlg.Database; |
30 | ············necessaryData = par; |
31 | ············return NdoDialogResult.OK; |
32 | ········} |
33 | |
34 | ········public override NdoDialogResult ShowConnectionDialog( ref string connectionString ) |
35 | ········{ |
36 | ············ConnectionDialog dlg = new ConnectionDialog( connectionString, false ); |
37 | ············if (dlg.ShowDialog() == DialogResult.Cancel) |
38 | ················return NdoDialogResult.Cancel; |
39 | ············connectionString = dlg.ConnectionString; |
40 | ············return NdoDialogResult.OK; |
41 | ········} |
42 | |
43 | ········public override string CreateDatabase( object necessaryData ) |
44 | ········{ |
45 | ············// Don't need to check, if type is OK, since that happens in CreateDatabase |
46 | ············NDOCreateDbParameter par = necessaryData as NDOCreateDbParameter; |
47 | |
48 | return Provider. CreateDatabase( par. DatabaseName, par. ConnectionString ) ; |
49 | ········} |
50 | ····} |
51 | } |
52 |
New Commit (947ce88)
1 | using NDO.UISupport; |
2 | using System; |
3 | using System.Collections.Generic; |
4 | using System.Linq; |
5 | using System.Text; |
6 | using System.Windows.Forms; |
7 | |
8 | namespace MySqlUISupport |
9 | { |
10 | ····public class MySqlUIProvider : DbUISupportBase |
11 | ····{ |
12 | ········public override string Name => "MySql"; |
13 | |
14 | ········public override NdoDialogResult ShowCreateDbDialog( ref object necessaryData ) |
15 | ········{ |
16 | ············NDOCreateDbParameter par; |
17 | ············if (necessaryData == null) |
18 | ················par = new NDOCreateDbParameter( string.Empty, "Data Source=localhost;User Id=root;" ); |
19 | ············else |
20 | ················par = necessaryData as NDOCreateDbParameter; |
21 | ············if (par == null) |
22 | ················throw new ArgumentException( "MySql provider: parameter type " + necessaryData.GetType().FullName + " is wrong.", "necessaryData" ); |
23 | ············if (par.ConnectionString == null || par.ConnectionString == string.Empty) |
24 | ················par.ConnectionString = "Data Source=localhost;User Id=root"; |
25 | ············ConnectionDialog dlg = new ConnectionDialog( par.ConnectionString, true ); |
26 | ············if (dlg.ShowDialog() == DialogResult.Cancel) |
27 | ················return NdoDialogResult.Cancel; |
28 | ············par.ConnectionString = dlg.ConnectionString; |
29 | ············par.DatabaseName = dlg.Database; |
30 | ············necessaryData = par; |
31 | ············return NdoDialogResult.OK; |
32 | ········} |
33 | |
34 | ········public override NdoDialogResult ShowConnectionDialog( ref string connectionString ) |
35 | ········{ |
36 | ············ConnectionDialog dlg = new ConnectionDialog( connectionString, false ); |
37 | ············if (dlg.ShowDialog() == DialogResult.Cancel) |
38 | ················return NdoDialogResult.Cancel; |
39 | ············connectionString = dlg.ConnectionString; |
40 | ············return NdoDialogResult.OK; |
41 | ········} |
42 | |
43 | ········public override string CreateDatabase( object necessaryData ) |
44 | ········{ |
45 | ············// Don't need to check, if type is OK, since that happens in CreateDatabase |
46 | ············NDOCreateDbParameter par = necessaryData as NDOCreateDbParameter; |
47 | |
48 | return EnsureProvider( ) . CreateDatabase( par. DatabaseName, par. ConnectionString ) ; |
49 | ········} |
50 | ····} |
51 | } |
52 |