Skip to content

Commit 3f88c46

Browse files
authored
Merge pull request #141 from snarlynarwhal/develop
Updated SerializedDictionary to implement IReadOnlyDictionary
2 parents b43ce82 + 7cf6a7a commit 3f88c46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Assets/Editor Toolbox/Runtime/Serialization/SerializedDictionary.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace UnityEngine
1010
/// Highly suggested to cast it to a <see cref="Dictionary{TKey, TValue}"/> when used in runtime.
1111
/// </summary>
1212
[Serializable]
13-
public sealed class SerializedDictionary<TK, TV> : IDictionary<TK, TV>, ISerializationCallbackReceiver
13+
public sealed class SerializedDictionary<TK, TV> : IDictionary<TK, TV>, IReadOnlyDictionary<TK, TV>, ISerializationCallbackReceiver
1414
{
1515
[Serializable]
1616
private struct KeyValuePair
@@ -224,6 +224,10 @@ public TV this[TK key]
224224

225225
public bool IsReadOnly => false;
226226

227+
IEnumerable<TK> IReadOnlyDictionary<TK, TV>.Keys => Keys;
228+
229+
IEnumerable<TV> IReadOnlyDictionary<TK, TV>.Values => Values;
230+
227231
public static implicit operator Dictionary<TK, TV>(SerializedDictionary<TK, TV> serializedDictionary)
228232
{
229233
return serializedDictionary.dictionary;
@@ -235,4 +239,4 @@ public static implicit operator SerializedDictionary<TK, TV>(Dictionary<TK, TV>
235239
}
236240
}
237241
}
238-
#endif
242+
#endif

0 commit comments

Comments
 (0)