using uCalcSoftware;
var uc = new uCalc();
var FruitsXML =
"""
""";
var t = new uCalc.Transformer();
var fruitsTagRule = t.FromTo("", "List of fruits");
var fruitRule = t.FromTo("CommonName={@string:name}", "- {name}");
Console.WriteLine("--- Using Maximum (Rule-Level Invalidation) ---");
// The fruitRule will fail because there are 4 fruits, exceeding the max of 3.
fruitRule.Maximum = 3;
t.Filter(FruitsXML);
Console.WriteLine($"Match count: {t.Matches.Count()}"); // The 'fruitsTagRule' still matches and is counted.
Console.WriteLine(t.Matches.Text);
Console.WriteLine("");
Console.WriteLine("--- Using GlobalMaximum (Transformer-Level Invalidation) ---");
fruitRule.Maximum = -1; // Reset local maximum to default (unlimited).
fruitRule.GlobalMaximum = 3; // The entire transformer will fail if more than 3 fruits are found.
t.Filter(FruitsXML);
Console.WriteLine($"Match count: {t.Matches.Count()}"); // All matches (including fruitsTagRule) are invalidated.
Console.WriteLine(t.Matches.Text);