상속: AbstractXmlBasedTemplate
예제 #1
0
 internal void LoadFromDocument(WordMLTemplate doc)
 {
     var buf = doc.GetBuffer();
     var newBuf = new byte[buf.Length];
     Buffer.BlockCopy(buf, 0, newBuf, 0, buf.Length);
     this.PutBuffer(newBuf);
 }
예제 #2
0
        public override IDocument Render(IDictionary<string, object> context)
        {
            Debug.Assert(this.engine != null);

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            //执行主要内容的渲染过程
            using (var inStream = new MemoryStream(base.GetBuffer(), false))
            using (var reader = new StreamReader(inStream, Encoding.UTF8))
            using (var ws = new MemoryStream())
            using (var writer = new StreamWriter(ws))
            {
                //执行渲染
                this.engine.Evaluate(context, reader, writer);
                writer.Flush();
                ws.Flush();
                var resultDoc = new WordMLTemplate();
                resultDoc.PutBuffer(ws.ToArray());
                return resultDoc;
            }
        }
예제 #3
0
 private static void WriteCompiledMainContent(WordMLTemplate t, XmlDocument xml)
 {
     using (var ms = new MemoryStream())
     using (var writer = new XmlTextWriter(ms, Encoding.UTF8))
     {
         writer.Formatting = Formatting.None;
         xml.WriteTo(writer);
         writer.Flush();
         ms.Flush();
         t.PutBuffer(ms.ToArray());
     }
 }