/// <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> /// <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]; if (!(value is IEnumerable enumerable)) { 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 scope.</param> /// <param name="arguments">The arguments passed to the tag.</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> /// <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); }
/// <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> /// <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 contextSource = arguments[contextParameter]; NestedContext context = new NestedContext() { KeyScope = keyScope.CreateChildScope(contextSource), 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 key scope.</param> /// <param name="arguments">The arguments passed to the tag.</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 contextSource = arguments[contextParameter]; NestedContext context = new NestedContext() { KeyScope = keyScope.CreateChildScope(contextSource), 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 key scope.</param> /// <param name="arguments">The arguments passed to the tag.</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; }