static string Render(string messageTemplate, params object[] properties)
 {
     var mt = new MessageTemplateParser().Parse(messageTemplate);
     var binder = new PropertyBinder(new PropertyValueConverter(Enumerable.Empty<Type>(), Enumerable.Empty<IDestructuringPolicy>()));
     var props = binder.ConstructProperties(mt, properties);
     var output = new StringBuilder();
     var writer = new StringWriter(output);
     mt.Render(props.ToDictionary(p => p.Name), writer);
     writer.Flush();
     return output.ToString();
 }
 public MessageTemplateProcessor(PropertyValueConverter propertyValueConverter)
 {
     _propertyValueConverter = propertyValueConverter;
     _propertyBinder = new PropertyBinder(_propertyValueConverter);
 }
 static IEnumerable<LogEventProperty> Capture(string messageTemplate, params object[] properties)
 {
     var mt = new MessageTemplateParser().Parse(messageTemplate);
     var binder = new PropertyBinder(
         new PropertyValueConverter(10, Enumerable.Empty<Type>(), Enumerable.Empty<IDestructuringPolicy>(), false));
     return binder.ConstructProperties(mt, properties);
 }
Beispiel #4
0
 public MessageTemplateProcessor(PropertyValueConverter propertyValueConverter)
 {
     _propertyValueConverter = propertyValueConverter;
     _propertyBinder         = new PropertyBinder(_propertyValueConverter);
 }
 static string Render(IFormatProvider formatProvider,
     string messageTemplate, params object[] properties)
 {
     var mt = new MessageTemplateParser().Parse(messageTemplate);
     var binder = new PropertyBinder(new PropertyValueConverter(10, Enumerable.Empty<Type>(), Enumerable.Empty<IDestructuringPolicy>()));
     var props = binder.ConstructProperties(mt, properties);
     var output = new StringBuilder();
     var writer = new StringWriter(output);
     var dict = System.Collections.Generic.Net40ReadOnlyDictionaryExtensions
         .ToDictionary40(props, p => p.Name, p => p.Value);
     mt.Render(dict, writer, formatProvider);
     writer.Flush();
     return output.ToString();
 }