public virtual void Handle()
{
if (!this.SkipValidation)
{
foreach (Token token in this.Tokens)
{
token.Validate();
}
}
this.GroupReferences();
foreach (string tagName in this.Groups.Keys)
{
List<Token> tokens = this.Groups[tagName];
if (tokens.Count > 0)
{
tokens[0].BeginHandle();
}
}
foreach (string tagName in this.Groups.Keys)
{
List<Token> tokens = this.Groups[tagName];
if (tokens.Count > 0)
{
tokens[0].EndHandle();
}
}
int counter = 0;
List<Token> selectorTokens = new List<Token>();
this.newText = this.TokensRegex.Replace(this.newText, delegate(Match m)
{
Token token = this.Tokens[counter++];
if(!token.Handled && token.Selector != null && token.Selector.Length > 0)
{
selectorTokens.Add(token);
return "";
}
return token.Handled ? "" : token.Output;
});
if (selectorTokens.Count > 0)
{
this.HandleSelectorTokens(selectorTokens);
}
}