ReplaceAction IReplacingCallback.Replacing(ReplacingArgs args)
{
// Create a builder to insert the field.
DocumentBuilder builder = new DocumentBuilder((Document)args.MatchNode.Document);
// Move to the first node of the match.
builder.MoveTo(args.MatchNode);
// If the user specified text to be used in the field as display text then use that, otherwise use the
// Match string as the display text.
string insertText;
if (!string.IsNullOrEmpty(mFieldText))
insertText = mFieldText;
else
insertText = args.Match.Value;
// Insert the TC field before this node using the specified string as the display text and user defined switches.
builder.InsertField(string.Format("TC \"{0}\" {1}", insertText, mFieldSwitches));
// We have done what we want so skip replacement.
return ReplaceAction.Skip;
}
}