mustache.KeyScope.Find C# (CSharp) Method

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
        internal object Find(string name)
        {
            string[] names = name.Split('.');
            string member = names[0];
            object nextLevel = _source;
            if (member != "this")
            {
                nextLevel = find(member);
            }
            for (int index = 1; index < names.Length; ++index)
            {
                IDictionary<string, object> context = toLookup(nextLevel);
                member = names[index];
                nextLevel = context[member];
            }
            return nextLevel;
        }

Usage Example

 /// <summary>
 /// Substitutes the key placeholders with their respective values.
 /// </summary>
 /// <param name="scope">The current lexical scope.</param>
 /// <returns>A dictionary associating the parameter name to the associated value.</returns>
 public Dictionary<string, object> GetArguments(KeyScope scope)
 {
     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
         {
             value = scope.Find(pair.Value);
         }
         arguments.Add(pair.Key.Name, value);
     }
     return arguments;
 }
All Usage Examples Of mustache.KeyScope::Find