Mustache.ArgumentCollection.GetArguments C# (CSharp) Méthode

GetArguments() public méthode

Substitutes the key placeholders with their respective values.
public GetArguments ( Scope keyScope, Scope contextScope ) : object>.Dictionary
keyScope Scope The key/value pairs in the current lexical scope.
contextScope Scope The key/value pairs in current context.
Résultat object>.Dictionary
        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;
        }

Usage Example

Exemple #1
0
        void IGenerator.GetText(TextWriter writer, Scope keyScope, Scope contextScope, Action <Substitution> postProcessor)
        {
            Dictionary <string, object> arguments = _arguments.GetArguments(keyScope, contextScope);
            IEnumerable <NestedContext> contexts  = _definition.GetChildContext(writer, keyScope, arguments, contextScope);
            List <IGenerator>           generators;

            if (_definition.ShouldGeneratePrimaryGroup(arguments))
            {
                generators = _primaryGenerators;
            }
            else
            {
                generators = new List <IGenerator>();
                if (_subGenerator != null)
                {
                    generators.Add(_subGenerator);
                }
            }
            foreach (NestedContext context in contexts)
            {
                foreach (IGenerator generator in generators)
                {
                    generator.GetText(context.Writer ?? writer, context.KeyScope ?? keyScope, context.ContextScope, postProcessor);
                    if (context.WriterNeedsConsidated)
                    {
                        writer.Write(_definition.ConsolidateWriter(context.Writer ?? writer, arguments));
                    }
                }
            }
        }
All Usage Examples Of Mustache.ArgumentCollection::GetArguments