Exemplo n.º 1
0
        static int _g_get_type(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                xc.DBManager.ColumnInfo __cl_gen_to_be_invoked = (xc.DBManager.ColumnInfo)translator.FastGetCSObj(L, 1);
                translator.Push(L, __cl_gen_to_be_invoked.type);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(1);
        }
Exemplo n.º 2
0
        static int _s_set_name(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                xc.DBManager.ColumnInfo __cl_gen_to_be_invoked = (xc.DBManager.ColumnInfo)translator.FastGetCSObj(L, 1);
                __cl_gen_to_be_invoked.name = LuaAPI.lua_tostring(L, 2);
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(0);
        }
Exemplo n.º 3
0
        static void PackRow(RealStatePtr L, SqliteDataReader data_reader, string table_name, bool has_column_info, List <xc.DBManager.ColumnInfo> column_info, int field_count)
        {
            for (int i = 0; i < field_count; ++i)
            {
                string field_name = "";
                Type   field_type = null;
                if (has_column_info)
                {
                    field_name = column_info[i].name;
                    field_type = column_info[i].type;
                }
                else
                {
                    field_name = data_reader.GetName(i);
                    field_type = data_reader.GetFieldType(i);

                    if (column_info != null)
                    {
                        var info = new xc.DBManager.ColumnInfo();
                        info.name = field_name;
                        info.type = field_type;

                        column_info.Add(info);
                    }
                }

                LuaAPI.lua_pushstring(L, field_name);

                if (field_type.Equals(typeof(string)))
                {
                    var str = data_reader.GetString(i);

                    // 如果指定列有中文,则通过翻译表的文本进行替换
                    var hasChineseChars = xc.DBCharIndex.Instance.HasChineseChars(table_name, field_name);
                    if (hasChineseChars)
                    {
                        str = xc.DBTranslate.Instance.GetTranslateText(table_name, str);
                    }

                    LuaAPI.lua_pushstring(L, str);
                }
                else if (field_type.IsValueType)
                {
                    LuaAPI.lua_pushnumber(L, Convert.ToDouble(data_reader.GetValue(i)));
                }
                else
                {
                    LuaAPI.lua_pushnil(L);
                }
                LuaAPI.lua_rawset(L, -3);
            }
        }
Exemplo n.º 4
0
        static int __CreateInstance(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    xc.DBManager.ColumnInfo __cl_gen_ret = new xc.DBManager.ColumnInfo();
                    translator.Push(L, __cl_gen_ret);
                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to xc.DBManager.ColumnInfo constructor!"));
        }