static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <MongoDB.Bson.BsonValue>(L, 3))
                {
                    string _name = LuaAPI.lua_tostring(L, 2);
                    MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonValue));

                    MongoDB.Bson.BsonElement gen_ret = new MongoDB.Bson.BsonElement(_name, _value);
                    translator.Push(L, gen_ret);

                    return(1);
                }

                if (LuaAPI.lua_gettop(L) == 1)
                {
                    translator.Push(L, default(MongoDB.Bson.BsonElement));
                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.BsonElement constructor!"));
        }
        private MongoDB.Bson.BsonDocument Swap(MongoDB.Bson.BsonDocument _doc)
        {
            var keys = JsonConvert.DeserializeObject <List <SwapKeyValue> >(this.SwapKeyValues);

            foreach (SwapKeyValue skv in keys)
            {
                MongoDB.Bson.BsonElement v = new MongoDB.Bson.BsonElement();
                if (_doc.TryGetElement(skv.Source, out v))
                {
                    _doc.Add(new MongoDB.Bson.BsonElement(skv.Destination, _doc[skv.Source]));
                    _doc.Remove(skv.Source);
                }
            }
            return(_doc);
        }
        static int _m_GetElement(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.MaterializedOnDemandBsonDocument gen_to_be_invoked = (MongoDB.Bson.MaterializedOnDemandBsonDocument)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    int _index = LuaAPI.xlua_tointeger(L, 2);

                    MongoDB.Bson.BsonElement gen_ret = gen_to_be_invoked.GetElement(_index);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _name = LuaAPI.lua_tostring(L, 2);

                    MongoDB.Bson.BsonElement gen_ret = gen_to_be_invoked.GetElement(_name);
                    translator.Push(L, 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 MongoDB.Bson.MaterializedOnDemandBsonDocument.GetElement!"));
        }
        static int _m_DeepClone(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.BsonElement gen_to_be_invoked; translator.Get(L, 1, out gen_to_be_invoked);



                {
                    MongoDB.Bson.BsonElement gen_ret = gen_to_be_invoked.DeepClone(  );
                    translator.Push(L, gen_ret);


                    translator.Update(L, 1, gen_to_be_invoked);


                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }