Find() private method

Attempts to find the value associated with the key with given name.
A key with the given name could not be found.
private Find ( string name ) : object
name string The name of the key.
return object
Ejemplo n.º 1
0
        void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
        {
            object value = _isVariable ? context.Find(_key, _shouldHtmlEscape) : scope.Find(_key, _shouldHtmlEscape);

            if (_shouldHtmlEscape)
            {
                writer.Write(_format, System.Net.WebUtility.HtmlEncode(value as string));
            }
            else
            {
                writer.Write(_format, value);
            }
        }
Ejemplo n.º 2
0
        void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
        {
            object value       = _isVariable ? context.Find(_key) : scope.Find(_key);
            var    formattable = value as IFormattable;

            if (formattable != null)
            {
                writer.Write(formattable.ToString(null, System.Threading.Thread.CurrentThread.CurrentCulture));
            }
            else
            {
                writer.Write(value);
            }
        }
Ejemplo n.º 3
0
        void IGenerator.GetText(TextWriter writer, Scope scope, Scope context, Action <Substitution> postProcessor)
        {
            object       value        = _isVariable ? context.Find(_key, _isExtension) : scope.Find(_key, _isExtension);
            string       result       = String.Format(writer.FormatProvider, _format, value);
            Substitution substitution = new Substitution()
            {
                Key         = _key,
                Substitute  = result,
                IsExtension = _isExtension
            };

            postProcessor(substitution);
            writer.Write(substitution.Substitute);
        }
 /// <summary>
 /// Substitutes the key placeholders with their respective values.
 /// </summary>
 /// <param name="keyScope">The key/value pairs in the current lexical scope.</param>
 /// <param name="contextScope">The key/value pairs in current context.</param>
 /// <returns>A dictionary associating the parameter name to the associated value.</returns>
 public Dictionary<string, object> GetArguments(Scope keyScope, Scope contextScope)
 {
     Dictionary<string, object> arguments = new Dictionary<string,object>();
     foreach (KeyValuePair<TagParameter, string> pair in _argumentLookup)
     {
         object value;
         if (pair.Value == null)
         {
             value = pair.Key.DefaultValue;
         }
         else if (pair.Value.StartsWith("@"))
         {
             value = contextScope.Find(pair.Value.Substring(1));
         }
         else
         {
             value = keyScope.Find(pair.Value);
         }
         arguments.Add(pair.Key.Name, value);
     }
     return arguments;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Substitutes the key placeholders with their respective values.
        /// </summary>
        /// <param name="keyScope">The key/value pairs in the current lexical scope.</param>
        /// <param name="contextScope">The key/value pairs in current context.</param>
        /// <returns>A dictionary associating the parameter name to the associated value.</returns>
        public Dictionary <string, object> GetArguments(Scope keyScope, Scope contextScope)
        {
            Dictionary <string, object> arguments = new Dictionary <string, object>();

            foreach (KeyValuePair <TagParameter, string> pair in _argumentLookup)
            {
                object value;
                if (pair.Value == null)
                {
                    value = pair.Key.DefaultValue;
                }
                else if (pair.Value.StartsWith("@"))
                {
                    value = contextScope.Find(pair.Value.Substring(1));
                }
                else
                {
                    value = keyScope.Find(pair.Value);
                }
                arguments.Add(pair.Key.Name, value);
            }
            return(arguments);
        }
Ejemplo n.º 6
0
 public object GetValue(Scope keyScope, Scope contextScope)
 {
     return(keyScope.Find(name));
 }
Ejemplo n.º 7
0
 public object GetValue(Scope keyScope, Scope contextScope)
 {
     return contextScope.Find(name);
 }
        void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
        {
            object value = _isVariable ? context.Find(_key) : scope.Find(_key);

            writer.Write(_format, value);
        }
Ejemplo n.º 9
0
 void IGenerator.GetText(Scope scope, TextWriter writer, Scope context)
 {
     object value = _isVariable ? context.Find(_key) : scope.Find(_key);
     writer.Write(_format, value);
 }