@@ -8,8 +8,8 @@ namespace Microsoft.AspNetCore.Components;
88/// <inheritdoc/>
99public class TempData : ITempData
1010{
11- private readonly Dictionary < string , object ? > _data = new ( ) ;
12- private readonly HashSet < string > _retainedKeys = new ( ) ;
11+ private readonly Dictionary < string , object ? > _data = new ( StringComparer . OrdinalIgnoreCase ) ;
12+ private readonly HashSet < string > _retainedKeys = new ( StringComparer . OrdinalIgnoreCase ) ;
1313
1414 /// <inheritdoc/>
1515 public object ? this [ string key ]
@@ -145,11 +145,40 @@ public void Clear()
145145
146146 IEnumerator < KeyValuePair < string , object ? > > IEnumerable < KeyValuePair < string , object ? > > . GetEnumerator ( )
147147 {
148- throw new NotImplementedException ( ) ;
148+ return new TempDataEnumerator ( this ) ;
149149 }
150150
151151 IEnumerator IEnumerable . GetEnumerator ( )
152152 {
153- throw new NotImplementedException ( ) ;
153+ return new TempDataEnumerator ( this ) ;
154+ }
155+
156+ class TempDataEnumerator : IEnumerator < KeyValuePair < string , object ? > >
157+ {
158+ private readonly IEnumerator < KeyValuePair < string , object ? > > _innerEnumerator ;
159+
160+ public TempDataEnumerator ( TempData tempData )
161+ {
162+ _innerEnumerator = tempData . _data . GetEnumerator ( ) ;
163+ }
164+
165+ public KeyValuePair < string , object ? > Current => _innerEnumerator . Current ;
166+
167+ object IEnumerator . Current => _innerEnumerator . Current ;
168+
169+ public void Dispose ( )
170+ {
171+ _innerEnumerator . Dispose ( ) ;
172+ }
173+
174+ public bool MoveNext ( )
175+ {
176+ return _innerEnumerator . MoveNext ( ) ;
177+ }
178+
179+ public void Reset ( )
180+ {
181+ _innerEnumerator . Reset ( ) ;
182+ }
154183 }
155184}
0 commit comments