TryFind() public method

public TryFind ( string name, object &value ) : bool
name string
value object
return bool
Ejemplo n.º 1
0
 /// <summary>
 /// Gets the text to output.
 /// </summary>
 /// <param name="writer">The writer to write the output to.</param>
 /// <param name="arguments">The arguments passed to the tag.</param>
 /// <param name="contextScope">Extra data passed along with the context.</param>
 public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope contextScope)
 {
     if (contextScope.TryFind("index", out object index))
     {
         writer.Write(index);
     }
 }
 /// <summary>
 /// Gets the text to output.
 /// </summary>
 /// <param name="writer">The writer to write the output to.</param>
 /// <param name="arguments">The arguments passed to the tag.</param>
 /// <param name="contextScope">Extra data passed along with the context.</param>
 public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope contextScope)
 {
     object index;
     if (contextScope.TryFind("index", out index))
     {
         writer.Write(Convert.ToInt32(index) % 2 == 0? "even" : "odd");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the text to output.
 /// </summary>
 /// <param name="writer">The writer to write the output to.</param>
 /// <param name="arguments">The arguments passed to the tag.</param>
 /// <param name="contextScope">Extra data passed along with the context.</param>
 public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope contextScope)
 {
     object index;
     if (contextScope.TryFind("index", out index))
     {
         writer.Write(index);
     }
 }
        /// <summary>
        /// Gets the text to output.
        /// </summary>
        /// <param name="writer">The writer to write the output to.</param>
        /// <param name="arguments">The arguments passed to the tag.</param>
        /// <param name="contextScope">Extra data passed along with the context.</param>
        public override void GetText(TextWriter writer, Dictionary <string, object> arguments, Scope contextScope)
        {
            object length;

            if (contextScope.TryFind("length", out length))
            {
                writer.Write(length);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the text to output.
        /// </summary>
        /// <param name="writer">The writer to write the output to.</param>
        /// <param name="arguments">The arguments passed to the tag.</param>
        /// <param name="contextScope">Extra data passed along with the context.</param>
        public override void GetText(TextWriter writer, Dictionary <string, object> arguments, Scope contextScope)
        {
            object val;

            if (contextScope.TryFind("value", out val))
            {
                writer.Write(val as string);
            }
        }
Ejemplo n.º 6
0
        public override IEnumerable <NestedContext> GetChildContext(TextWriter writer, Scope keyScope, Dictionary <string, object> arguments, Scope contextScope)
        {
            object appendable;

            if (contextScope.TryFind("beforeappend", out appendable))
            {
                if (appendable.ToString().ToLowerInvariant() != "true")
                {
                    return(new List <NestedContext>());
                }
                return(base.GetChildContext(writer, keyScope, arguments, contextScope));
            }
            return(base.GetChildContext(writer, keyScope, arguments, contextScope));
        }
        public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope context)
        {
            var str = arguments["string"] as string;

            if (str == null) return;

            object indexObj;
            if (!context.TryFind("index", out indexObj)) return;
            
            var index = (int) indexObj;

            if (index > 0)
            {
                writer.Write(str);
            }
        }