static IEnumerable <LogEventProperty> Capture(string messageTemplate, params object[] properties)
        {
            var mt     = new MessageTemplateParser().Parse(messageTemplate);
            var binder = new PropertyBinder(
                new PropertyValueConverter(10, 1000, 1000, Enumerable.Empty <Type>(), Enumerable.Empty <IDestructuringPolicy>(), false));

            return(binder.ConstructProperties(mt, properties).Select(p => new LogEventProperty(p.Name, p.Value)));
        }
示例#2
0
        static string Render(IFormatProvider formatProvider, string messageTemplate, params object[] properties)
        {
            var mt     = new MessageTemplateParser().Parse(messageTemplate);
            var binder = new PropertyBinder(new PropertyValueConverter(10, 1000, 1000, Enumerable.Empty <Type>(), Enumerable.Empty <IDestructuringPolicy>(), false));
            var props  = binder.ConstructProperties(mt, properties);
            var output = new StringBuilder();
            var writer = new StringWriter(output);

            mt.Render(props.ToDictionary(p => p.Name, p => p.Value), writer, formatProvider);
            writer.Flush();
            return(output.ToString());
        }