@@ -39,6 +39,17 @@ module ExtraTopLevelOperators =
39
39
t.[ RuntimeHelpers.StructBox( k)] <- v
40
40
let d = ( t :> IDictionary<_,_>)
41
41
let c = ( t :> ICollection<_>)
42
+
43
+ let dictEnumerator ( a : System.Collections.Generic.IEnumerator < System.Collections.DictionaryEntry >) =
44
+ { new System.Collections.IDictionaryEnumerator with
45
+ member x.Current = a.Current :> obj
46
+ member x.Entry = a.Current
47
+ member x.Key = x.Entry.Key
48
+ member x.Value = x.Entry.Value
49
+ member x.MoveNext () = a.MoveNext()
50
+ member x.Reset () = a.Reset()
51
+ }
52
+
42
53
// Give a read-only view of the dictionary
43
54
{ new IDictionary< 'Key, 'T> with
44
55
member s.Item
@@ -108,7 +119,8 @@ module ExtraTopLevelOperators =
108
119
member s.Add ( k , v ) = raise ( NotSupportedException( SR.GetString( SR.thisValueCannotBeMutated)))
109
120
member s.Contains ( k ) = d.ContainsKey( RuntimeHelpers.StructBox( k :?> 'Key))
110
121
member s.GetEnumerator () =
111
- (( c |> Seq.map ( fun ( KeyValue ( k , v )) -> System.Collections.DictionaryEntry( k.Value, v))) :> System.Collections.IDictionary) .GetEnumerator()
122
+ ( c |> Seq.map ( fun ( KeyValue ( k , v )) -> System.Collections.DictionaryEntry( k.Value, v))) .GetEnumerator()
123
+ |> dictEnumerator
112
124
113
125
member s.Remove ( k ) = ( raise ( NotSupportedException( SR.GetString( SR.thisValueCannotBeMutated))) : unit)
114
126
member s.Clear () = raise ( NotSupportedException( SR.GetString( SR.thisValueCannotBeMutated)));
0 commit comments