Malt.Reporting.OpenDocument.OdfTemplate.Render C# (CSharp) 메소드

Render() 공개 메소드

public Render ( object>.IDictionary context ) : IDocument
context object>.IDictionary
리턴 IDocument
        public override IDocument Render(IDictionary<string, object> context)
        {
            Debug.Assert(this.engine != null);

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

            var resultDoc = new OdfTemplate();
            this.CopyTo(resultDoc);

            var userImages = new Dictionary<Image, string>();

            this.ResetTextEngine(userImages, resultDoc);

            using (var inStream = this.GetEntryInputStream(this.MainContentEntryPath))
            using (var reader = new StreamReader(inStream, Encoding.UTF8))
            using (var ws = resultDoc.GetEntryOutputStream(resultDoc.MainContentEntryPath))
            using (var writer = new StreamWriter(ws))
            {
                this.engine.Evaluate(context, reader, writer);
            }

            return resultDoc;
        }

Usage Example

예제 #1
0
 /// <summary>
 /// 一部执行模板编译、渲染并返回结果
 /// </summary>
 /// <param name="odfPath"></param>
 /// <returns></returns>
 public static OdfTemplate RenderTemplate(string odfPath, IDictionary<string, object> context)
 {
     var odf = new OdfTemplate();
     odf.Load(odfPath);
     odf.Compile();
     var resultDoc = odf.Render(context);
     return resultDoc as OdfTemplate;
 }