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)); }
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)); }