Ejemplo n.º 1
0
        private BsonValue GetBsonValueWithField(LogEventInfo logEvent, MongoDBLayoutField field)
        {
            var type   = field.BsonType;
            var layout = field.Layout;

            if (layout == null)
            {
                return(null);
            }
            var value = RenderLogEvent(layout, logEvent);

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            return(BsonValueConverter.Convert(value, type));
        }
        private BsonValue GetBsonValueWithField(LogEventInfo logEvent, MongoDBLayoutField field)
        {
            var type   = field.BsonType;
            var layout = field.Layout;

            if (layout == null)
            {
                return(null);
            }
            var value = RenderLogEvent(layout, logEvent);

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            BsonValue bsonValue;

            if (!BsonTypeMapper.TryMapToBsonValue(value, out bsonValue))
            {
                bsonValue = bsonValue.ToBsonDocument();
            }
            return(bsonValue);
        }