Repeat dictionary implementation
Inheritance: IRepeatDictionary
Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }