I'm trying to develop my own sink, but I'm stuck in the tokens extraction step which I need in order to customize rendering style (colors etc). In a normal message template I can call MessageTemplateParser, but I didn't saw any equivalent parser for ExpressionTemplate. I tried with MessageTemplateParser like this:
var template = new MessageTemplateParser().Parse("[{@t:HH:mm:ss} {@l:u3}{#if SourceContext is not null} ({SourceContext}){#end}] {@m}\n{@x}");
Although properties seems to be extracted, the list also includes the expression language like for example {#if SourceContext is not null}
(recognized as a token of Text type) and this mess up everything.
ITextFormatter
contains a CompiledTemplateBlock
with all the elements I'm looking for (CompiledLiteralText
, CompiledExceptionToken
etc), but they are not exposed.
How would be the correct way to parse an ExpressionTemplate (apart from replicate the entire CompiledTemplateBlock
source tree, of course!) ?