diff --git a/ExternalProjects/NLua/src/LuaTable.cs b/ExternalProjects/NLua/src/LuaTable.cs index a6827ca54c..a503ca702a 100644 --- a/ExternalProjects/NLua/src/LuaTable.cs +++ b/ExternalProjects/NLua/src/LuaTable.cs @@ -7,13 +7,16 @@ using NLua.Native; namespace NLua { - public class LuaTable : LuaBase + public class LuaTable : LuaBase, IReadOnlyDictionary { - public ICollection/*?*/ Keys + public int Count + => Wrapped?.Count ?? default; + + public IEnumerable/*?*/ Keys => Wrapped?.Keys; - public ICollection Values - => Wrapped?.Values as ICollection ?? Array.Empty(); + public IEnumerable Values + => Wrapped?.Values as IReadOnlyCollection ?? Array.Empty(); private Dictionary/*?*/ Wrapped => TryGet(out var lua) ? lua.GetTableDict(this) : null; @@ -56,8 +59,17 @@ namespace NLua } } - public IDictionaryEnumerator/*?*/ GetEnumerator() - => Wrapped?.GetEnumerator(); + public bool ContainsKey(object key) + => Wrapped?.ContainsKey(key) ?? false; + + public Dictionary.Enumerator GetEnumerator() + => Wrapped?.GetEnumerator() ?? default; + + IEnumerator> IEnumerable>.GetEnumerator() + => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); /// /// Gets an string fields of a table ignoring its metatable, @@ -74,5 +86,12 @@ namespace NLua public override string ToString() => "table"; + + public bool TryGetValue(object key, out object/*?*/ value) + { + if (Wrapped is Dictionary dict) return dict.TryGetValue(key, out value); + value = default; + return default; + } } } diff --git a/References/NLua.dll b/References/NLua.dll index 55fbdb8d2c..dc3149b9cf 100644 Binary files a/References/NLua.dll and b/References/NLua.dll differ