本文整理汇总了C#中Rule.AddWatcher方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.AddWatcher方法的具体用法?C# Rule.AddWatcher怎么用?C# Rule.AddWatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.AddWatcher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEngine
public static void TestEngine()
{
TagReplacementWatchers watchers;
DataLookupTag dlt;
Rule rule;
RuleSet rules = new RuleSet();
rule = new Rule("root");
rule.Priority = 2; rule.MinPriority = 1;
rule.Output = new Content();
rule.Output.Add("Hello. ");
rule.Output.Add(new Tag("cats"));
rule.Expression = Expression.Parse("value? 2 >=");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("cats");
rule.Output = new Content();
dlt = new DataLookupTag("value");
dlt.AddWatcher(new CardinalFilter());
rule.Output.Add(dlt);
rule.Output.Add(" (");
rule.Output.Add(new DataLookupTag("value"));
rule.Output.Add(") cat");
dlt = new DataLookupTag("value");
dlt.AddWatcher(new PluraliseFilter());
rule.Output.Add(dlt);
rule.Output.Add(" in a bag, here is the ");
dlt = new DataLookupTag("value");
dlt.AddWatcher(new OrdinalFilter());
rule.Output.Add(dlt);
rule.Output.Add(" (");
dlt = new DataLookupTag("value");
dlt.AddWatcher(new OrdinalSuffixFilter());
rule.Output.Add(dlt);
rule.Output.Add(")");
rule.AddWatcher(new SentenceFilter());
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("root");
rule.Frequency = 2;
rule.Output = new Content();
rule.Output.Add("Hi ");
watchers = new TagReplacementWatchers();
watchers.Add(new AsClause("name"));
rule.Output.Add(new Tag("nickname", watchers));
rule.Output.Add("! Do you mind if I call you '");
rule.Output.Add(new DataLookupTag("name"));
rule.Output.Add("'?");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("nickname");
rule.Output = new Content();
rule.Output.Add("mate");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("nickname");
rule.Output = new Content();
rule.Output.Add("buddy");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("nickname");
rule.Output = new Content();
rule.Output.Add("dude");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("nickname");
rule.Output = new Content();
rule.Output.Add("man");
rules.Add(rule);
Console.WriteLine(rule.ToString());
rule = new Rule("nickname");
rule.Output = new Content();
rule.Output.Add("friendo");
rules.Add(rule);
Console.WriteLine(rule.ToString());
Engine engine = new Engine(rules);
Namespace data = new Namespace();
data.Set("value", 2);
string result = engine.Run("root", data);
Console.WriteLine("........................................................................");
Console.WriteLine(result);
Console.WriteLine("........................................................................");
Console.WriteLine("Final data:");
Console.WriteLine(data.ToString(" "));
}