本文整理汇总了C#中Rule.Evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.Evaluate方法的具体用法?C# Rule.Evaluate怎么用?C# Rule.Evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.Evaluate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start ()
{
Board board = new Board(3,3);
board.SetPiece(0,0, Piece.DiePiece("One","White"));
board.SetPiece(0,1, Piece.DiePiece("Two","White"));
board.SetPiece(0,2, Piece.DiePiece("Three", "Black"));
Rule rule1 = new Rule(new AllHave(new PropertyCheckers.PropertyHasValue("Face","One")));
Rule rule2 = new Rule(new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Face","One")));
Rule rule3 = new Rule(new AllHave(new PropertyCheckers.Not(new PropertyCheckers.PropertyHasValue("Colour","Blue"))));
Rule rule4 = new Rule(new FaceSum(new Comparers<int>.LessThan(), 7));
Rule rule5 = new Rule(new PropertyCount(new PropertyCheckers.PropertyHasValue("Face","One"),new Comparers<int>.Equal(), 1));
System.Diagnostics.Debug.Assert(rule1.Evaluate(board) == false);
System.Diagnostics.Debug.Assert(rule2.Evaluate(board) == true);
System.Diagnostics.Debug.Assert(rule3.Evaluate(board) == true);
System.Diagnostics.Debug.Assert(rule4.Evaluate(board) == true);
System.Diagnostics.Debug.Assert(rule5.Evaluate(board) == true);
Debug.Log (rule1.ToString());
rule2.And(rule4);
Debug.Log (rule2.ToString());
Rule rule6 = new Rule(new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Face","One")));
Rule rule7 = new Rule(new FaceSum(new Comparers<int>.LessThan(), 7));
rule6.And(rule7);
Debug.Log (rule6.ToString());
System.Diagnostics.Debug.Assert(rule2.Evaluate(board) == true);
}
示例2: EvaluateShouldExecuteCallback
public void EvaluateShouldExecuteCallback()
{
// arrange
var executed = false;
var target = new Rule<string>( s => executed = ( s == "unit test" ) );
// act
target.Evaluate( "unit test" );
// assert
Assert.True( executed );
}
示例3: collectFiredRules
private static void collectFiredRules(OrderedDictionary/*<String, SimpleRule>*/ firedRules, Rule rule, Dictionary<string, object> dict/*, EvaluationContext context*/)
{
/*Predicate predicate = rule.getPredicate();
if(predicate == null){
throw new InvalidFeatureException(rule);
}
Boolean status = PredicateUtil.evaluate(predicate, context);
if(status == null || !status.booleanValue()){
return;
} // End if*/
PredicateResult status = rule.Evaluate(dict);
if (status == PredicateResult.Unknown || status == PredicateResult.False) {
return;
}
if (rule is SimpleRule) {
SimpleRule simpleRule = (SimpleRule)rule;
firedRules.Add(simpleRule.Score, simpleRule);
} else {
if (rule is CompoundRule)
{
CompoundRule compoundRule = (CompoundRule)rule;
foreach(Rule childRule in compoundRule.Rules){
collectFiredRules(firedRules, childRule, dict);
}
} else {
throw new PmmlException("Type of Rule not supported");
}
}
}