public static void Format(
            [NotNull] LogEvent @event,
            [NotNull] TextWriter writer,
            [CanBeNull] object value,
            [CanBeNull] string format = null,
            [CanBeNull] IFormatProvider formatProvider = null)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            if (value is OperationContextValue contextValue)
            {
                value = contextValue.ToString();
            }

            if (value is not string template || !TemplateTokenizer.CanContainNamedTokens(template))
            {
                PropertyValueFormatter.Format(writer, value, format, formatProvider);
                return;
            }

            var tokens = TemplatesCache.ObtainTokens(template);

            PaddingFormatHelper.TryParseFormat(format, out var insertLeadingSpace, out var insertTrailingSpace);

            if (insertLeadingSpace)
            {
                writer.WriteSpace();
            }

            foreach (var token in tokens)
            {
                token.Render(@event, writer, formatProvider);
            }

            if (insertTrailingSpace)
            {
                writer.WriteSpace();
            }
        }
 public void ResetTemplatesCache()
 {
     _state = null;
 }