protected override void BeforeFormat(INoticeMessage message, ITagValue[] tagsValues) { _nvelocityContext = new VelocityContext(); _nvelocityContext.AttachEventCartridge(new EventCartridge()); _nvelocityContext.EventCartridge.ReferenceInsertion += EventCartridgeReferenceInsertion; foreach (var tagValue in tagsValues) { _nvelocityContext.Put(tagValue.Tag, tagValue.Value); } base.BeforeFormat(message, tagsValues); }
private VelocityContext CreateVelocityContext(IDictionary<string, object> context) { Debug.Assert(context != null); var vctx = new VelocityContext(); EventCartridge eventCart = new EventCartridge(); eventCart.ReferenceInsertion += this.OnReferenceInsertion; vctx.AttachEventCartridge(eventCart); //添加转义工具 vctx.Put(VelocityEscapeTool.DefaultKey, VelocityEscapeTool.Instance); foreach (var item in context) { vctx.Put(item.Key, item.Value); } return vctx; }
private VelocityContext CreateContext(IDictionary context) { var velocityContext = new VelocityContext(new Hashtable(context)); velocityContext.AttachEventCartridge(EscapeUtils.EscapableEventCartridge); return velocityContext; }