public void Serialize(MongoDB.Bson.IO.BsonWriter bsonWriter, Type nominalType, IBsonSerializationOptions options)
 {
     if (nominalType != typeof(FieldsWrapper))
     {
         throw new ArgumentException("Cannot serialize anything but self");
     }
     bsonWriter.WriteStartDocument();
     foreach (var dataFieldValue in DataFieldValues)
     {
         bsonWriter.WriteName(dataFieldValue.LocalIdentifier);
         if (dataFieldValue.Values.Count != 1)
         {
             var list = new string[dataFieldValue.Values.Count];
             for (int i = 0; i < dataFieldValue.Values.Count; i++)
             {
                 list[i] = dataFieldValue.Values[i];
             }
             BsonSerializer.Serialize(bsonWriter, list);
         }
         else
         {
             BsonSerializer.Serialize(bsonWriter, dataFieldValue.Values[0]);
         }
     }
     bsonWriter.WriteEndDocument();
 }
        static int _g_get_Disposed(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                MongoDB.Bson.IO.BsonWriter gen_to_be_invoked = (MongoDB.Bson.IO.BsonWriter)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushboolean(L, gen_to_be_invoked.Disposed);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
 public override void Serialize(MongoDB.Bson.IO.BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
 {
     if (value == null)
     {
         bsonWriter.WriteNull();
     }
     else
     {
         var query = (QueryDocument)value;
         var json  = query.ToJson();
         bsonWriter.WriteString(json);
     }
 }
Beispiel #4
0
    void IBsonSerializer.Serialize(MongoDB.Bson.IO.BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
    {
        MyClassA item = (MyClassA)value;

        if (item.myClassD != null)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                item.myClassD.Save(item.myClassD, stream);
                mesure.myClassDBin = stream.ToArray();
            }
        }
        else
        {
            item.myClassDBin = null;
        }
        _classMapSerializer.Serialize(bsonWriter, nominalType, item, options);
        item.myClassDBin = null;
    }
        static int _m_WriteUndefined(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


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



                {
                    gen_to_be_invoked.WriteUndefined(  );



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


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



                {
                    MongoDB.Bson.BsonRegularExpression _regex = (MongoDB.Bson.BsonRegularExpression)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonRegularExpression));

                    gen_to_be_invoked.WriteRegularExpression(_regex);



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


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



                {
                    long _value = LuaAPI.lua_toint64(L, 2);

                    gen_to_be_invoked.WriteTimestamp(_value);



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


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



                {
                    string _code = LuaAPI.lua_tostring(L, 2);

                    gen_to_be_invoked.WriteJavaScriptWithScope(_code);



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


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



                {
                    MongoDB.Bson.IO.IByteBuffer _slice = (MongoDB.Bson.IO.IByteBuffer)translator.GetObject(L, 2, typeof(MongoDB.Bson.IO.IByteBuffer));

                    gen_to_be_invoked.WriteRawBsonDocument(_slice);



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


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



                {
                    MongoDB.Bson.Decimal128 _value; translator.Get(L, 2, out _value);

                    gen_to_be_invoked.WriteDecimal128(_value);



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


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



                {
                    MongoDB.Bson.BsonBinaryData _binaryData = (MongoDB.Bson.BsonBinaryData)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonBinaryData));

                    gen_to_be_invoked.WriteBinaryData(_binaryData);



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


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



                {
                    System.Action <MongoDB.Bson.IO.BsonWriterSettings> _configurator = translator.GetDelegate <System.Action <MongoDB.Bson.IO.BsonWriterSettings> >(L, 2);

                    gen_to_be_invoked.PushSettings(_configurator);



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


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



                {
                    MongoDB.Bson.IO.IElementNameValidator _validator = (MongoDB.Bson.IO.IElementNameValidator)translator.GetObject(L, 2, typeof(MongoDB.Bson.IO.IElementNameValidator));

                    gen_to_be_invoked.PushElementNameValidator(_validator);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Beispiel #14
0
 //  MongoDB stores all datetime as Utc, any datetime value DateTimeKind is not DateTimeKind.Utc, will be converted to Utc first
 //  We overwrite it to be DateTimeKind.Utc, becasue we want to preserve the raw value
 public override void Serialize(MongoDB.Bson.IO.BsonWriter bsonWriter, System.Type nominalType, object value, MongoDB.Bson.Serialization.IBsonSerializationOptions options)
 {
     var dt = (DateTime) value;
     var utcValue = new DateTime(dt.Ticks, DateTimeKind.Utc);
     base.Serialize(bsonWriter, nominalType, utcValue, options);
 }