/// <summary> /// EndProcessing method. /// </summary> protected override void EndProcessing() { var group = new TemplateGroupString(Definition) { Listener = new ErrorListener(this) }; var groupInfo = new TemplateGroupInfo(group); group.RegisterModelAdaptor(typeof(PSObject), new PSObjectAdaptor()); group.RegisterModelAdaptor(typeof(Type), new TypeAdapter()); group.RegisterRenderer(typeof(DateTime), new DateRenderer()); group.RegisterRenderer(typeof(DateTimeOffset), new DateRenderer()); group.Listener = ErrorManager.DefaultErrorListener; WriteObject(groupInfo); }
public string Parse(string templateKey, IDictionary <string, object> model) { var group = new TemplateGroupString("group", "delimiters \"$\", \"$\"\r\nt(x) ::= \" $ x $ \""); var renderer = new AdvancedRenderer(); group.RegisterRenderer(typeof(DateTimeOffset), renderer); group.RegisterRenderer(typeof(DateTime), renderer); group.RegisterRenderer(typeof(double), renderer); group.RegisterRenderer(typeof(decimal), renderer); var templateContent = _templateProvider.GetContentsFor(templateKey, model); group.DefineTemplate("template", templateContent, new[] { "Model" }); var stringTemplate = group.GetInstanceOf("template"); stringTemplate.Add("Model", model); return(stringTemplate.Render()); }