本文整理汇总了C#中Rule.And方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.And方法的具体用法?C# Rule.And怎么用?C# Rule.And使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.And方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MainWindow
public MainWindow()
{
this.InitializeComponent();
SDateField dep = new SDateField();
SDateField ret = new SDateField();
Rule r1 = new Rule((d, r) => d <= r);
Rule r2 = new Rule((d, r) => !Unlucky(d) && !Unlucky(r));
Rule rule = r1.And(r2);
Cell<bool> valid = rule.Reify(dep.SelectedDate, ret.SelectedDate);
SButton ok = new SButton(valid) { Content = "OK", Width = 75 };
this.DeparturePlaceholder.Children.Add(dep);
this.ReturnPlaceholder.Children.Add(ret);
this.ButtonPlaceholder.Children.Add(ok);
}