Repeat dictionary implementation
Наследование: IRepeatDictionary
Пример #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);
            }
        }
Пример #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);
            }
        }