| 621 | int enumerable_pairs_func = -1; |
| 622 | |
| 623 | internal void CreateEnumerablePairs(RealStatePtr L) |
| 624 | { |
| 625 | LuaFunction func = luaEnv.DoString(@" |
| 626 | return function(obj) |
| 627 | local isKeyValuePair |
| 628 | local function lua_iter(cs_iter, k) |
| 629 | if cs_iter:MoveNext() then |
| 630 | local current = cs_iter.Current |
| 631 | if isKeyValuePair == nil then |
| 632 | if type(current) == 'userdata' then |
| 633 | local t = current:GetType() |
| 634 | isKeyValuePair = t.Name == 'KeyValuePair`2' and t.Namespace == 'System.Collections.Generic' |
| 635 | else |
| 636 | isKeyValuePair = false |
| 637 | end |
| 638 | --print(current, isKeyValuePair) |
| 639 | end |
| 640 | if isKeyValuePair then |
| 641 | return current.Key, current.Value |
| 642 | else |
| 643 | return k + 1, current |
| 644 | end |
| 645 | end |
| 646 | end |
| 647 | return lua_iter, obj:GetEnumerator(), -1 |
| 648 | end |
| 649 | ")[0] as LuaFunction; |
| 650 | func.push(L); |
| 651 | enumerable_pairs_func = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); |
| 652 | func.Dispose(); |
| 653 | } |
| 654 | |
| 655 | public void OpenLib(RealStatePtr L) |
| 656 | { |