Skip to content

Commit cc99574

Browse files
committed
feat(DataTableManager) Get will now get DataTable directly, not an object
1 parent 5e8a509 commit cc99574

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

SharpEngine.Core/Manager/DataTableManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ namespace SharpEngine.Core.Manager;
1111
/// </summary>
1212
public static class DataTableManager
1313
{
14-
private static readonly Dictionary<string, IDataTable> DataTables = [];
14+
private static readonly Dictionary<string, object> DataTables = [];
1515

1616
/// <summary>
1717
/// List of known data tables
1818
/// </summary>
19-
public static List<string> DataTableNames => new(DataTables.Keys);
19+
public static List<string> DataTableNames => [.. DataTables.Keys];
2020

2121
/// <summary>
2222
/// Checks if a data table with the specified name exists.
@@ -48,7 +48,7 @@ public static void RemoveDataTable(string name)
4848
/// </summary>
4949
/// <param name="name">Name of the data table</param>
5050
/// <param name="dataTable">Data table to add</param>
51-
public static void AddDataTable(string name, IDataTable dataTable)
51+
public static void AddDataTable<T>(string name, IDataTable<T> dataTable) where T : class
5252
{
5353
if (!DataTables.TryAdd(name, dataTable))
5454
DebugManager.Log(
@@ -58,17 +58,16 @@ public static void AddDataTable(string name, IDataTable dataTable)
5858
}
5959

6060
/// <summary>
61-
/// Get an object from the specified data table.
61+
/// Get specified data table.
6262
/// </summary>
6363
/// <typeparam name="T">Type of the object</typeparam>
6464
/// <param name="dataTable">Name of the data table</param>
65-
/// <param name="predicate">Predicate to filter the object</param>
66-
/// <returns>The object from the data table</returns>
65+
/// <returns>The data table</returns>
6766
/// <exception cref="ArgumentException">Thrown if the data table is not found</exception>
68-
public static T? Get<T>(string dataTable, Predicate<dynamic?> predicate)
67+
public static IDataTable<T> Get<T>(string dataTable) where T : class
6968
{
7069
if (DataTables.TryGetValue(dataTable, out var dTable))
71-
return dTable.Get(predicate);
70+
return (IDataTable<T>)dTable;
7271
DebugManager.Log(
7372
LogLevel.LogError,
7473
$"SE_DATATABLEMANAGER: DataTable not found : {dataTable}"

0 commit comments

Comments
 (0)