コード例 #1
0
 public ThemedMessageTemplateRenderer(HtmlTheme theme, ThemedValueFormatter valueFormatter, bool isLiteral)
 {
     _theme                  = theme ?? throw new ArgumentNullException(nameof(theme));
     _valueFormatter         = valueFormatter;
     _isLiteral              = isLiteral;
     _unthemedValueFormatter = valueFormatter.SwitchTheme(NoTheme);
 }
コード例 #2
0
        int RenderValue(HtmlTheme theme, ThemedValueFormatter valueFormatter, LogEventPropertyValue propertyValue, TextWriter output, string format)
        {
            if (_isLiteral && propertyValue is ScalarValue sv && sv.Value is string)
            {
                using (theme.Apply(output, HtmlThemeStyle.String))
                    output.Write(sv.Value);
                return(0);
            }

            return(valueFormatter.Format(propertyValue, output, format, _isLiteral));
        }
コード例 #3
0
        public PropertiesTokenRenderer(HtmlTheme theme, PropertyToken token, MessageTemplate outputTemplate)
        {
            _outputTemplate = outputTemplate;
            _theme          = theme ?? throw new ArgumentNullException(nameof(theme));
            _token          = token ?? throw new ArgumentNullException(nameof(token));
            var isJson = false;

            if (token.Format != null)
            {
                for (var i = 0; i < token.Format.Length; ++i)
                {
                    if (token.Format[i] == 'j')
                    {
                        isJson = true;
                    }
                }
            }

            _valueFormatter = isJson
                ? (ThemedValueFormatter) new ThemedJsonValueFormatter(theme)
                : new ThemedDisplayValueFormatter(theme);
        }