CreateChildScope() public method

Creates a child scope that searches for keys in a default dictionary of key/value pairs.
public CreateChildScope ( ) : Scope
return Scope
Ejemplo n.º 1
0
        /// <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;
            }
        }
Ejemplo n.º 2
0
 /// <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;
     }
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
 /// <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;
 }