cosmetics

This commit is contained in:
UbitUmarov
2026-07-18 00:27:29 +01:00
parent 1b428a1825
commit 87fc4c1f51
6 changed files with 38 additions and 52 deletions

View File

@@ -39,7 +39,7 @@ namespace OpenSim.Data.MySQL
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Dictionary<string, FieldInfo> m_Fields = new Dictionary<string, FieldInfo>();
protected Dictionary<string, FieldInfo> m_Fields = [];
protected List<string> m_ColumnNames = null;
protected string m_Realm;
@@ -71,7 +71,7 @@ namespace OpenSim.Data.MySQL
if (!string.IsNullOrEmpty(storeName))
{
// We always use a new connection for any Migrations
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
using (MySqlConnection dbcon = new(m_connectionString))
{
dbcon.Open();
Migration m = new Migration(dbcon, Assembly, storeName);
@@ -101,7 +101,7 @@ namespace OpenSim.Data.MySQL
if (m_ColumnNames != null)
return;
List<string> columnNames = new List<string>();
List<string> columnNames = [];
DataTable schemaTable = reader.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
@@ -116,7 +116,7 @@ namespace OpenSim.Data.MySQL
public virtual T[] Get(string field, string key)
{
using (MySqlCommand cmd = new MySqlCommand())
using (MySqlCommand cmd = new())
{
cmd.Parameters.AddWithValue(field, key);
cmd.CommandText = $"select * from {m_Realm} where `{field}` = ?{field}";
@@ -128,7 +128,7 @@ namespace OpenSim.Data.MySQL
{
int flen = keys.Length;
if(flen == 0)
return new T[0];
return [];
int flast = flen - 1;
StringBuilder sb = new StringBuilder(1024);
@@ -144,7 +144,7 @@ namespace OpenSim.Data.MySQL
if(i < flast)
sb.Append(",?");
else
sb.Append(")");
sb.Append(')');
}
cmd.CommandText = sb.ToString();
return DoQuery(cmd);
@@ -153,14 +153,14 @@ namespace OpenSim.Data.MySQL
public virtual T[] Get(string[] fields, string[] keys)
{
return Get(fields, keys, String.Empty);
return Get(fields, keys, string.Empty);
}
public virtual T[] Get(string[] fields, string[] keys, string options)
{
int flen = fields.Length;
if (flen == 0 || flen != keys.Length)
return new T[0];
return [];
int flast = flen - 1;
StringBuilder sb = new StringBuilder(1024);
@@ -188,7 +188,7 @@ namespace OpenSim.Data.MySQL
{
if (m_trans == null)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
using (MySqlConnection dbcon = new(m_connectionString))
{
dbcon.Open();
T[] ret = DoQueryWithConnection(cmd, dbcon);
@@ -211,14 +211,14 @@ namespace OpenSim.Data.MySQL
protected T[] DoQueryWithConnection(MySqlCommand cmd, MySqlConnection dbcon)
{
List<T> result = new List<T>();
List<T> result = [];
cmd.Connection = dbcon;
using (IDataReader reader = cmd.ExecuteReader())
using (MySqlDataReader reader = cmd.ExecuteReader())
{
if (reader == null)
return new T[0];
return [];
CheckColumnNames(reader);
@@ -259,14 +259,13 @@ namespace OpenSim.Data.MySQL
if (m_DataField != null)
{
Dictionary<string, string> data =
new Dictionary<string, string>();
Dictionary<string, string> data = [];
foreach (string col in m_ColumnNames)
{
data[col] = reader[col].ToString();
if (data[col] == null)
data[col] = String.Empty;
data[col] = string.Empty;
}
m_DataField.SetValue(row, data);
@@ -281,10 +280,9 @@ namespace OpenSim.Data.MySQL
public virtual T[] Get(string where)
{
using (MySqlCommand cmd = new MySqlCommand())
using (MySqlCommand cmd = new())
{
cmd.CommandText = $"select * from {m_Realm} where {where}"; ;
cmd.CommandText = $"select * from {m_Realm} where {where}";
return DoQuery(cmd);
}
}
@@ -293,11 +291,11 @@ namespace OpenSim.Data.MySQL
{
//m_log.DebugFormat("[MYSQL GENERIC TABLE HANDLER]: Store(T row) invoked");
using (MySqlCommand cmd = new MySqlCommand())
using (MySqlCommand cmd = new())
{
string query = "";
List<String> names = new List<String>();
List<String> values = new List<String>();
List<string> names = [];
List<string> values = [];
foreach (FieldInfo fi in m_Fields.Values)
{
@@ -340,7 +338,7 @@ namespace OpenSim.Data.MySQL
public virtual bool Delete(string field, string key)
{
return Delete(new string[] { field }, new string[] { key });
return Delete([field], [key]);
}
public virtual bool Delete(string[] fields, string[] keys)
@@ -375,7 +373,7 @@ namespace OpenSim.Data.MySQL
public long GetCount(string field, string key)
{
return GetCount(new string[] { field }, new string[] { key });
return GetCount([field], [key]);
}
public long GetCount(string[] fields, string[] keys)
@@ -388,7 +386,7 @@ namespace OpenSim.Data.MySQL
StringBuilder sb = new StringBuilder(1024);
sb.AppendFormat("select count(*) from {0} where ", m_Realm);
using (MySqlCommand cmd = new MySqlCommand())
using (MySqlCommand cmd = new())
{
for (int i = 0 ; i < flen ; i++)
{
@@ -408,12 +406,9 @@ namespace OpenSim.Data.MySQL
public long GetCount(string where)
{
using (MySqlCommand cmd = new MySqlCommand())
using (MySqlCommand cmd = new() )
{
string query = String.Format("select count(*) from {0} where {1}",
m_Realm, where);
cmd.CommandText = query;
cmd.CommandText = $"select count(*) from {m_Realm} where {where}";
object result = DoQueryScalar(cmd);