public override IEnumerable <NestedContext> GetChildContext(
            TextWriter writer,
            Scope keyScope,
            Dictionary <string, object> arguments,
            Scope contextScope)
        {
            object contextSource = arguments[ContextParameter];

            Scope scope;

            if (contextSource == null)
            {
                scope = keyScope.CreateChildScope();
            }
            else
            {
                scope = keyScope.CreateChildScope(contextSource);
            }

            NestedContext context = new NestedContext()
            {
                KeyScope     = scope,
                Writer       = writer,
                ContextScope = contextScope.CreateChildScope()
            };

            yield return(context);
        }
        /// <summary>
        /// Gets the context to use when building the inner text of the tag.
        /// </summary>
        /// <param name="writer">The text writer passed</param>
        /// <param name="keyScope">The current scope.</param>
        /// <param name="arguments">The arguments passed to the tag.</param>
        /// <param name="contextScope">The scope context.</param>
        /// <returns>The scope to use when building the inner text of the tag.</returns>
        public override IEnumerable <NestedContext> GetChildContext(
            TextWriter writer,
            Scope keyScope,
            Dictionary <string, object> arguments,
            Scope contextScope)
        {
            object      value      = arguments[CollectionParameter];
            IEnumerable enumerable = value as IEnumerable;

            if (enumerable == null)
            {
                yield break;
            }

            int index = 0;

            foreach (object item in enumerable)
            {
                NestedContext childContext = new NestedContext()
                {
                    KeyScope     = keyScope.CreateChildScope(item),
                    Writer       = writer,
                    ContextScope = contextScope.CreateChildScope(),
                };
                childContext.ContextScope.Set("index", index);
                yield return(childContext);

                ++index;
            }
        }
        /// <summary>
        /// Gets the context to use when building the inner text of the tag.
        /// </summary>
        /// <param name="writer">The text writer passed</param>
        /// <param name="keyScope">The current key scope.</param>
        /// <param name="arguments">The arguments passed to the tag.</param>
        /// <param name="contextScope">The scope context.</param>
        /// <returns>The scope to use when building the inner text of the tag.</returns>
        public virtual IEnumerable <NestedContext> GetChildContext(
            TextWriter writer,
            Scope keyScope,
            Dictionary <string, object> arguments,
            Scope contextScope)
        {
            NestedContext context = new NestedContext()
            {
                KeyScope     = keyScope,
                Writer       = writer,
                ContextScope = contextScope.CreateChildScope()
            };

            yield return(context);
        }