Repeat dictionary implementation
Inheritance: IRepeatDictionary
コード例 #1
0
ファイル: Template.cs プロジェクト: lck/SharpTAL
        public void Render(StreamWriter outputWriter, Dictionary <string, object> globals)
        {
            CompileCheck(globals);

            try
            {
                IRenderContext context = new RenderContext();

                foreach (var item in globals)
                {
                    context[item.Key] = item.Value;
                }

                context["__FormatResult"]  = new Func <object, string>(FormatResult);
                context["__IsFalseResult"] = new Func <object, bool>(IsFalseResult);

                if (!context.ContainsKey("repeat"))
                {
                    context["repeat"] = new RepeatDictionary();
                }

                _templateInfo.RenderMethod.Invoke(null, new object[] { outputWriter, context });
            }
            catch (TargetInvocationException ex)
            {
                throw new RenderTemplateException(_templateInfo, ex.InnerException.Message, ex.InnerException);
            }
            catch (Exception ex)
            {
                throw new RenderTemplateException(_templateInfo, ex.Message, ex);
            }
        }
コード例 #2
0
ファイル: Template.cs プロジェクト: kooboo-jifeng/SharpTAL
        public void Render(StreamWriter outputWriter, Dictionary<string, object> globals)
        {
            CompileCheck(globals);

            try
            {
                IRenderContext context = new RenderContext();

                foreach (var item in globals)
                    context[item.Key] = item.Value;

                context["__FormatResult"] = new Func<object, string>(FormatResult);
                context["__IsFalseResult"] = new Func<object, bool>(IsFalseResult);

                if (!context.ContainsKey("repeat"))
                    context["repeat"] = new RepeatDictionary();

                _templateInfo.RenderMethod.Invoke(null, new object[] { outputWriter, context });
            }
            catch (TargetInvocationException ex)
            {
                throw new RenderTemplateException(_templateInfo, ex.InnerException.Message, ex.InnerException);
            }
            catch (Exception ex)
            {
                throw new RenderTemplateException(_templateInfo, ex.Message, ex);
            }
        }