From ae8ab04e8ad72955f3661bb8d6821f36f7605bba Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Thu, 3 Dec 2020 14:25:38 +1030 Subject: [PATCH] Change BanManager.Bans to a readonly dictionary Entries to this dictionary should be added through `InsertBan` rather than directly to the dictionary --- TShockAPI/DB/BanManager.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index 6122b133..7e195507 100644 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Collections.Generic; using System.Data; using MySql.Data.MySqlClient; +using System.Collections.ObjectModel; namespace TShockAPI.DB { @@ -34,9 +35,9 @@ namespace TShockAPI.DB private Dictionary _bans; /// - /// Dictionary of Bans, keyed on ban ticket number + /// Readonly dictionary of Bans, keyed on ban ticket number. /// - public Dictionary Bans + public ReadOnlyDictionary Bans { get { @@ -45,7 +46,7 @@ namespace TShockAPI.DB _bans = RetrieveAllBans().ToDictionary(b => b.TicketNumber); } - return _bans; + return new ReadOnlyDictionary(_bans); } }