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));
}
}
}
}