diff --git a/Libraries/UniversalEditor.Essential/ObjectModels/Database/DatabaseTable.cs b/Libraries/UniversalEditor.Essential/ObjectModels/Database/DatabaseTable.cs index 80842dfa..48df391a 100755 --- a/Libraries/UniversalEditor.Essential/ObjectModels/Database/DatabaseTable.cs +++ b/Libraries/UniversalEditor.Essential/ObjectModels/Database/DatabaseTable.cs @@ -20,6 +20,7 @@ // along with this program. If not, see . using System; +using System.Collections.Generic; namespace UniversalEditor.ObjectModels.Database { @@ -31,6 +32,33 @@ namespace UniversalEditor.ObjectModels.Database public class DatabaseTableCollection : System.Collections.ObjectModel.Collection { + public DatabaseTable this[string name] + { + get + { + if (_itemsByName.ContainsKey(name)) + return _itemsByName[name]; + return null; + } + } + + private Dictionary _itemsByName = new Dictionary(); + protected override void ClearItems() + { + base.ClearItems(); + _itemsByName.Clear(); + } + protected override void InsertItem(int index, DatabaseTable item) + { + base.InsertItem(index, item); + _itemsByName[item.Name] = item; + } + protected override void RemoveItem(int index) + { + if (_itemsByName.ContainsKey(this[index].Name)) + _itemsByName.Remove(this[index].Name); + base.RemoveItem(index); + } } ///