本文整理汇总了C#中Rule.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Rule.ToString方法的具体用法?C# Rule.ToString怎么用?C# Rule.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DoubleNegationTest
public void DoubleNegationTest()
{
Atom A = new AllHave(new PropertyCheckers.PropertyHasValue("Face", "One"));
Rule rule1 = new Rule(new Not(new Not(A)));
Assert.AreEqual("NOT (NOT (AllHave [Face == One]))", rule1.ToString());
Assert.AreEqual("AllHave [Face == One]", rule1.ToNormalForm().ToString());
}
示例3: ComplexTest
public void ComplexTest()
{
Atom A = new AllHave(new PropertyCheckers.PropertyHasValue("Face", "One"));
Atom B = new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Colour", "Black"));
Rule rule1 = new Rule(new Not(new Not(new Or(new Not(new And(A,B)), B))));
Assert.AreEqual("NOT (NOT ((NOT ((AllHave [Face == One]) AND (ExistsOneHas [Colour == Black]))) OR (ExistsOneHas [Colour == Black])))", rule1.ToString());
Assert.AreEqual("((ExistsOneHas [NOT (Face == One)]) OR (AllHave [NOT (Colour == Black)])) OR (ExistsOneHas [Colour == Black])", rule1.ToNormalForm().ToString());
}
示例4: Start
// Use this for initialization
void Start ()
{
Atom A = new AllHave(new PropertyCheckers.PropertyHasValue("Face","One"));
Atom B = new ExistsOneHas(new PropertyCheckers.PropertyHasValue("Colour", "Black"));
Rule rule1 = new Rule(new Not(new And(A,B)));
Rule rule2 = new Rule(new Or(A.Negate(), B.Negate()));
Debug.Log (rule1.ToString());
Debug.Log (rule2.ToString());
Debug.Log (rule1.ToNormalForm().ToString());
Debug.Log (rule2.ToNormalForm().ToString());
Debug.Log ("Unormalised - " + rule1.Equals(rule2));
Debug.Log ("Normalised - " + rule1.ToNormalForm().Equals(rule2.ToNormalForm()));
}
示例5: 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(" "));
}
示例6: GetCacheKey
private static string GetCacheKey(int pageid, string rule, Rule.Direction direction)
{
return "Relations-" + pageid + "-" + rule + "-" + direction.ToString();
}
示例7: ChangeUser
private void ChangeUser(Rule R)
{
var err = (int)0;
List<User> LU;
var file = File.OpenRead("Logs");
var sz = new XmlSerializer(typeof(List<User>));
if (file.Length != 0)
{
LU = (List<User>)sz.Deserialize(file);
}
else
{
LU = new List<User>();
}
file.Close();
if (err == 0)
{
File.Delete("Logs");
file = File.OpenWrite("Logs");
LU[listBox2.SelectedIndex].UserRule = R;
sz.Serialize(file, LU);
file.Close();
Program.SessionLog.Add(string.Format("{0};{1}-Пользователь {2} изменил уровень доступа для {3} на {4} !", DateTime.Now.ToString(), SesUs.UserRule, SesUs.Login, listBox2.SelectedItem, R.ToString()));
}
}