C#のDicをLuaのTable&&C#のListをLuaのTableにする

792 ワード

function UIUtils.DicToTable(CSharpDic)
    -- C# Dic  Lua Table
    local dic = {}
    if CSharpDic then
        local iter = CSharpDic:GetEnumerator()
        while iter:MoveNext() do
            local k = iter.Current.Key
            local v = iter.Current.Value
            dic[k] = v
        end
    end
    return dic
end
function UIUtils.ListToTable(CSharpList)
    -- C# List  Lua Table
    local list = {}
    if CSharpList then
        local index = 1
        local iter = CSharpList:GetEnumerator()
        while iter:MoveNext() do
            local v = iter.Current
            list[index] = v
            index = index + 1
        end
    else
        logError("Error,CSharpList is null")
    end
    return list
end