Beispiel #1
0
 public void RuleSetTest1()
 {
     string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10";
     var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "", "", new RuleOptions());
     RTRuleSet rules = new RTRuleSet(srcText, new[] { rule });
     string result = rules.ExecuteAll();
     Assert.AreEqual(result, "");
 }
Beispiel #2
0
 public void RuleSetTest5()
 {
     string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10";
     var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "[@{(:: var1 (+ 1 1)) (::var2 (+ var1 1)) (+ var1 var2 11)@}]", "@{(merge)@}", new RuleOptions());
     RTRuleSet rules = new RTRuleSet(srcText, new[] { rule });
     string result = rules.ExecuteAll();
     Assert.AreEqual(result, "[16] [16] [16] [16] [16]");
 }
Beispiel #3
0
 public RTRuleSet(string srcText, RTRuleData[] rulesData)
 {
     this._rules = new RTRule[rulesData.Length];
     for (int i = 0; i < this._rules.Length; i++)
     {
         this._rules[i] = new RTRule(rulesData[i]);
     }
     SourceText = srcText;
 }
Beispiel #4
0
 public void RuleSetTest7()
 {
     string srcText = @"1, 2 3, 4 5, 6 7, 8 9, 10";
     var rule = new RTRuleData(@"(\d+)\s*,\s*(\d+)", "[@{ (:: add1 (+ x 1)) (add1 6) @}]", "@{(merge)@}", new RuleOptions());
     RTRuleSet rules = new RTRuleSet(srcText, new[] { rule });
     string result = rules.ExecuteAll();
     Assert.AreEqual(result, "[7] [7] [7] [7] [7]");
 }
Beispiel #5
0
 public void TestGetFunction()
 {
     string srcText = @"goose says this is very good.";
     var rule = new RTRuleData(@"g(o)+[ds]", "[@{($1)@}]", "@{(merge)@}", new RuleOptions());
     RTRuleSet rules = new RTRuleSet(srcText, new[] { rule });
     string result = rules.ExecuteAll();
     Assert.AreEqual("[o]e says this is very [o].", result);
 }
 /// <summary>
 /// Append a rule in the list view.
 /// </summary>
 /// <param name="rule"></param>
 private void AppendRule(RTRuleData rule)
 {
     ListViewItem lvi = new ListViewItem();
     lvi.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
     lvi.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
     var ruleui = new RuleBox();
     ruleui.RuleData = rule;
     lvi.Content = ruleui;
     var ruleCollection = RuleList.Items;
     int count = ruleCollection.Count;
     ruleui.Index = count;
     ruleCollection.Insert(count, lvi);
     RuleList.SelectedIndex = count;
 }
Beispiel #7
0
 public RTRuleSet(RTRuleData[] rulesData)
     : this(null, rulesData)
 {
 }
Beispiel #8
0
 public void AddRule(RTRuleData rule)
 {
     Rules.Add(rule);
 }