/// <summary> /// 将数组转换为BsonArray以放入MongoDB,数组中每个元素都可转换为BsonDocument /// </summary> /// <param name="obj">待转换的数组对象</param> /// <returns>转换后的BsonArray对象</returns> public static MongoDB.Bson.BsonArray ToMongoArray(object obj) { object[] objs = (object[])obj; MongoDB.Bson.BsonArray array = new MongoDB.Bson.BsonArray(); for (int i = 0; i < objs.Length; ++i) { array.Add(ToMongoDocument(objs[i])); } return(array); }
static int _m_Add(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.BsonArray gen_to_be_invoked = (MongoDB.Bson.BsonArray)translator.FastGetCSObj(L, 1); { MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonValue)); MongoDB.Bson.BsonArray gen_ret = gen_to_be_invoked.Add(_value); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }