Removed not needed class. Switch strings to use the new c# style

This commit is contained in:
hondacrx
2017-07-14 22:18:14 -04:00
parent 2123d2bd78
commit 34263f9551
5 changed files with 49 additions and 76 deletions
+13 -13
View File
@@ -30,18 +30,18 @@ namespace Framework.Database
_updateFlags = ConfigMgr.GetDefaultValue("Updates.EnableDatabases", defaultUpdateMask);
}
public void AddDatabase<T>(MySqlBase<T> database, string name)
public void AddDatabase<T>(MySqlBase<T> database, string dbName)
{
bool updatesEnabled = database.IsAutoUpdateEnabled(_updateFlags);
_open.Add(() =>
{
ConnectionObject connectionObject = new ConnectionObject
MySqlConnectionInfo connectionObject = new MySqlConnectionInfo
{
Database = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Database", ""),
Host = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Host", ""),
Password = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Password", ""),
Port = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Port", ""),
Username = ConfigMgr.GetDefaultValue(name + "DatabaseInfo.Username", "")
Host = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Host", ""),
Port = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Port", ""),
Username = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Username", ""),
Password = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Password", ""),
Database = ConfigMgr.GetDefaultValue(dbName + "DatabaseInfo.Database", "")
};
var error = database.Initialize(connectionObject);
@@ -50,14 +50,14 @@ namespace Framework.Database
// Database does not exist
if (error == MySqlErrorCode.UnknownDatabase && updatesEnabled && _autoSetup)
{
Log.outInfo(LogFilter.ServerLoading, "Database \"{0}\" does not exist, do you want to create it? [yes (default) / no]: ", name);
Log.outInfo(LogFilter.ServerLoading, $"Database \"{dbName}\" does not exist, do you want to create it? [yes (default) / no]: ");
string answer = Console.ReadLine();
if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
return false;
Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name);
string sqlString = string.Format("CREATE DATABASE `{0}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", name);
Log.outInfo(LogFilter.ServerLoading, $"Creating database \"{dbName}\"...");
string sqlString = $"CREATE DATABASE `{dbName}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
// Try to create the database and connect again if auto setup is enabled
if (database.Apply(sqlString) && database.Initialize(connectionObject) == MySqlErrorCode.None)
error = MySqlErrorCode.None;
@@ -66,7 +66,7 @@ namespace Framework.Database
// If the error wasn't handled quit
if (error != MySqlErrorCode.None)
{
Log.outError(LogFilter.ServerLoading, "\nDatabase {0} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.", name);
Log.outError(LogFilter.ServerLoading, $"\nDatabase {dbName} NOT opened. There were errors opening the MySQL connections. Check your SQLErrors for specific errors.");
return false;
}
@@ -84,7 +84,7 @@ namespace Framework.Database
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
if (!database.GetUpdater().Populate())
{
Log.outError(LogFilter.ServerLoading, "Could not populate the {0} database, see log for details.", name);
Log.outError(LogFilter.ServerLoading, $"Could not populate the {dbName} database, see log for details.");
return false;
}
return true;
@@ -96,7 +96,7 @@ namespace Framework.Database
database.Apply("SET GLOBAL max_allowed_packet=1073741824;");
if (!database.GetUpdater().Update())
{
Log.outError(LogFilter.ServerLoading, "Could not update the {0} database, see log for details.", name);
Log.outError(LogFilter.ServerLoading, $"Could not update the {dbName} database, see log for details.");
return false;
}
return true;