Example #1
0
        public override void Write(TextWriter writer, Context context)
        {
            var items = context.GetValues(_expression).ToArray();

            int index = 0;

            foreach (var item in items)
            {
                try
                {
                    var meta = new Dictionary <string, object>(StringComparer.Ordinal)
                    {
                        { "@index", index },
                        { "@first", index == 0 },
                        { "@last", index == items.Length - 1 }
                    };

                    context.Push(item, meta);
                    _content.Write(writer, context);
                    index++;
                }
                finally
                {
                    context.Pop();
                }
            }
        }
Example #2
0
        public override void Write(TextWriter writer, Context context)
        {
            var items = context.GetValues(_expression).ToArray();

            int index = 0;
            foreach (var item in items)
            {
                try
                {
                    var meta = new Dictionary<string, object>(StringComparer.Ordinal)
                    {
                        {"@index", index},
                        {"@first", index == 0},
                        {"@last", index == items.Length - 1}
                    };

                    context.Push(item, meta);
                    _content.Write(writer, context);
                    index++;
                }
                finally
                {
                    context.Pop();
                }
            }
        }
Example #3
0
        public override void Write(TextWriter writer, Context context)
        {
            var value = context.GetValue(_expression);
            if (value.IsNullOrNoValue()) return;

            try
            {
                context.Push(value, null);
                _content.Write(writer, context);
            }
            catch (Exception)
            {
                context.Pop();
            }
        }
Example #4
0
        public override void Write(TextWriter writer, Context context)
        {
            var value = context.GetValue(_expression);

            if (value.IsNullOrNoValue())
            {
                return;
            }

            try
            {
                context.Push(value, null);
                _content.Write(writer, context);
            }
            catch (Exception)
            {
                context.Pop();
            }
        }