Exemple #1
0
        static int _g_get_Value(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                MongoDB.Bson.BsonString gen_to_be_invoked = (MongoDB.Bson.BsonString)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushstring(L, gen_to_be_invoked.Value);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
Exemple #2
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _value = LuaAPI.lua_tostring(L, 2);

                    MongoDB.Bson.BsonString gen_ret = new MongoDB.Bson.BsonString(_value);
                    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.BsonString constructor!"));
        }
Exemple #3
0
        static int __EqMeta(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                if (translator.Assignable <MongoDB.Bson.BsonString>(L, 1) && translator.Assignable <MongoDB.Bson.BsonString>(L, 2))
                {
                    MongoDB.Bson.BsonString leftside  = (MongoDB.Bson.BsonString)translator.GetObject(L, 1, typeof(MongoDB.Bson.BsonString));
                    MongoDB.Bson.BsonString rightside = (MongoDB.Bson.BsonString)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonString));

                    LuaAPI.lua_pushboolean(L, leftside == rightside);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to right hand of == operator, need MongoDB.Bson.BsonString!"));
        }
Exemple #4
0
        static int _m_Create_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    object _value = translator.GetObject(L, 1, typeof(object));

                    MongoDB.Bson.BsonString gen_ret = MongoDB.Bson.BsonString.Create(_value);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Exemple #5
0
        static int _m_ToInt64(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


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



                {
                    long gen_ret = gen_to_be_invoked.ToInt64(  );
                    LuaAPI.lua_pushint64(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Exemple #6
0
        static int _m_Equals(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


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


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonString>(L, 2))
                {
                    MongoDB.Bson.BsonString _rhs = (MongoDB.Bson.BsonString)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonString));

                    bool gen_ret = gen_to_be_invoked.Equals(_rhs);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && translator.Assignable <object>(L, 2))
                {
                    object _obj = translator.GetObject(L, 2, typeof(object));

                    bool gen_ret = gen_to_be_invoked.Equals(_obj);
                    LuaAPI.lua_pushboolean(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.BsonString.Equals!"));
        }
Exemple #7
0
        static int _m_CompareTo(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


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


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonString>(L, 2))
                {
                    MongoDB.Bson.BsonString _other = (MongoDB.Bson.BsonString)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonString));

                    int gen_ret = gen_to_be_invoked.CompareTo(_other);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonValue>(L, 2))
                {
                    MongoDB.Bson.BsonValue _other = (MongoDB.Bson.BsonValue)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonValue));

                    int gen_ret = gen_to_be_invoked.CompareTo(_other);
                    LuaAPI.xlua_pushinteger(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.BsonString.CompareTo!"));
        }
Exemple #8
0
        public async Task <object> SaveBOsAsync(List <BO2> bos)
        {
            var saveBOs       = new List <string>();
            var updateOptions = new UpdateOptions {
                IsUpsert = true
            };
            var filterDict = new Dictionary <string, object[]>();

            filterDict["bot"] = new object[] { string.Empty };
            filterDict["bo"]  = new object[] { string.Empty };
            foreach (var bo in bos)
            {
                filterDict["bot"][0] = bo.BOT;
                filterDict["bo"][0]  = bo.BO;
                var filter = this.BOBsonDocumentCollection.BuildFilter(filterDict);
                using (var cursor = (await this.BOBsonDocumentCollection.FindAsync(filter)))
                {
                    var oldDoc = await cursor.FirstOrDefaultAsync();

                    if (oldDoc == null)
                    {
                        var doc = ConvertFrom <BO2>(bo);
                        await this.BOBsonDocumentCollection.ReplaceOneAsync(filter, doc, updateOptions);

                        saveBOs.Add(bo.BO);
                        continue;
                    }
                    if (!bo.BOID.IsNullOrEmpty())
                    {
                        oldDoc["boid"] = new MongoDB.Bson.BsonString(bo.BOID);
                    }
                    if (!bo.Alias.IsNullOrEmpty())
                    {
                        oldDoc["alias"] = new MongoDB.Bson.BsonArray(bo.Alias);
                    }
                    if (bo.Location != null)
                    {
                        var js  = bo.Location.ToJson();
                        var doc = MongoDB.Bson.BsonDocument.Parse(js);
                        oldDoc["location"] = doc;
                    }
                    if (!bo.Properties.IsNullOrEmpty())
                    {
                        var oldProperties = oldDoc["properties"];
                        if (oldProperties == null)
                        {
                            oldDoc["properties"] = MongoDB.Bson.BsonValue.Create(bo.Properties);
                        }
                        else
                        {
                            foreach (var pair in bo.Properties)
                            {
                                oldProperties[pair.Key] = MongoDB.Bson.BsonValue.Create(pair.Value);
                            }
                        }
                    }
                    await this.BOBsonDocumentCollection.ReplaceOneAsync(filter, oldDoc, updateOptions);

                    saveBOs.Add(bo.BO);
                }
            }
            return(saveBOs);
        }