Some refactorings
This commit is contained in:
14
TrackerLibrary/Enums.cs
Normal file
14
TrackerLibrary/Enums.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TrackerLibrary
|
||||
{
|
||||
public enum DatabaseType
|
||||
{
|
||||
Sql,
|
||||
TextFile
|
||||
}
|
||||
}
|
||||
@ -8,22 +8,26 @@ namespace TrackerLibrary
|
||||
{
|
||||
public static class GlobalConfig
|
||||
{
|
||||
public static List<IDataConnection> Connections { get; private set; } = new List<IDataConnection>();
|
||||
public static void InitializeConnections(bool database, bool textFiles)
|
||||
public static IDataConnection Connection { get; private set; }
|
||||
public static void InitializeConnections(DatabaseType db)
|
||||
{
|
||||
if (database)
|
||||
|
||||
switch (db)
|
||||
{
|
||||
// TODO - Set up the sql connector properly !
|
||||
SqlConnector sql = new SqlConnector();
|
||||
Connections.Add(sql);
|
||||
case DatabaseType.Sql:
|
||||
// TODO - Set up the sql connector properly !
|
||||
SqlConnector sql = new SqlConnector();
|
||||
Connection = sql;
|
||||
break;
|
||||
case DatabaseType.TextFile:
|
||||
// TODO - Create the text Connection
|
||||
TextConnector text = new TextConnector();
|
||||
Connection = text;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (textFiles)
|
||||
{
|
||||
// TODO - Create the text Connection
|
||||
TextConnector text = new TextConnector();
|
||||
Connections.Add(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
<Compile Include="DataAccess\IDataConnection.cs" />
|
||||
<Compile Include="DataAccess\SqlConnector.cs" />
|
||||
<Compile Include="DataAccess\TextConnector.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="GlobalConfig.cs" />
|
||||
<Compile Include="Models\MatchupEntryModel.cs" />
|
||||
<Compile Include="Models\MatchupModel.cs" />
|
||||
|
||||
@ -29,10 +29,7 @@ namespace TrackerUI
|
||||
prizeAmountValue.Text,
|
||||
prizePercentageValue.Text);
|
||||
|
||||
foreach (var db in GlobalConfig.Connections)
|
||||
{
|
||||
db.CreatePrize(model);
|
||||
}
|
||||
GlobalConfig.Connection.CreatePrize(model);
|
||||
|
||||
placeNameValue.Text = "";
|
||||
placeNumberValue.Text = "";
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TrackerLibrary;
|
||||
|
||||
namespace TrackerUI
|
||||
{
|
||||
@ -18,7 +19,7 @@ namespace TrackerUI
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
// Initialize the database connections
|
||||
TrackerLibrary.GlobalConfig.InitializeConnections(true, true);
|
||||
GlobalConfig.InitializeConnections(DatabaseType.Sql);
|
||||
Application.Run(new CreatePrizeForm());
|
||||
|
||||
//Application.Run(new TournamentDashboardForm());
|
||||
|
||||
Reference in New Issue
Block a user