Ejemplo n.º 1
0
        private BsonValue GetBsonValueWithLayout <T>(LogEventInfo logEvent, string layoutText)
        {
            var layout = Layout.FromString(layoutText);
            var value  = RenderLogEvent(layout, logEvent);

            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            return(BsonValueConverter.Convert <T>(value));
        }
Ejemplo n.º 2
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));
        }