本文整理汇总了C#中Condition.And方法的典型用法代码示例。如果您正苦于以下问题:C# Condition.And方法的具体用法?C# Condition.And怎么用?C# Condition.And使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition.And方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAndCondition
public void TestAndCondition()
{
Condition condition = new Condition("1", "==", "1");
Assert.IsTrue(condition.Evaluate(null));
condition.And(new Condition("2", "==", "2"));
Assert.IsTrue(condition.Evaluate(null));
condition.And(new Condition("2", "==", "1"));
Assert.IsFalse(condition.Evaluate(null));
}
示例2: GetCondition
public static Condition GetCondition(string conStr)
{
// syntax needs to be copnfirmed at this stage
List<string> expressions = R.Scan(conStr, ExpressionsAndOperators);
expressions.Reverse();
string syntax = expressions.Shift();
if (string.IsNullOrEmpty(syntax))
throw new SyntaxException("Condition syntax in Section tag is incorrect.");
Match syntaxMatch = ExpressionSyntax.Match(syntax);
if (!syntaxMatch.Success)
throw new SyntaxException("Condition syntax in Section tag is incorrect.");
Condition condition = new Condition(syntaxMatch.Groups[1].Value,
syntaxMatch.Groups[2].Value, syntaxMatch.Groups[3].Value);
while (expressions.Any())
{
string @operator = expressions.Shift().Trim();
Match expressionMatch = ExpressionSyntax.Match(expressions.Shift());
if (!expressionMatch.Success)
throw new SyntaxException("Condition syntax in Section tag is incorrect.");
Condition newCondition = new Condition(expressionMatch.Groups[1].Value,
expressionMatch.Groups[2].Value, expressionMatch.Groups[3].Value);
switch (@operator)
{
case "and":
newCondition.And(condition);
break;
case "or":
newCondition.Or(condition);
break;
}
condition = newCondition;
}
return condition;
}
示例3: PushBlock
private void PushBlock(string tag, string markup)
{
Condition block;
if (tag == "else")
{
block = new ElseCondition();
}
else
{
List<string> expressions = R.Scan(markup, ExpressionsAndOperatorsRegex);
// last item in list
string syntax = expressions.TryGetAtIndexReverse(0);
if (string.IsNullOrEmpty(syntax))
throw new SyntaxException(SyntaxHelp);
Match syntaxMatch = Syntax.Match(syntax);
if (!syntaxMatch.Success)
throw new SyntaxException(SyntaxHelp);
Condition condition = new Condition(syntaxMatch.Groups[1].Value,
syntaxMatch.Groups[2].Value, syntaxMatch.Groups[3].Value);
// continue to process remaining items in the list backwards, in pairs
for (int i = 1; i < expressions.Count; i = i + 2)
{
string @operator = expressions.TryGetAtIndexReverse(i).Trim();
Match expressionMatch = Syntax.Match(expressions.TryGetAtIndexReverse(i + 1));
if (!expressionMatch.Success)
throw new SyntaxException(SyntaxHelp);
Condition newCondition = new Condition(expressionMatch.Groups[1].Value,
expressionMatch.Groups[2].Value, expressionMatch.Groups[3].Value);
switch (@operator)
{
case "and":
newCondition.And(condition);
break;
case "or":
newCondition.Or(condition);
break;
}
condition = newCondition;
}
block = condition;
}
Blocks.Add(block);
NodeList = block.Attach(new List<object>());
}
示例4: PushBlock
private void PushBlock(string tag, string markup)
{
Condition block;
if (tag == "else")
{
block = new ElseCondition();
}
else
{
List<string> expressions = R.Scan(markup, ExpressionsAndOperators);
expressions.Reverse();
string syntax = expressions.Shift();
if (string.IsNullOrEmpty(syntax))
throw new SyntaxException(SyntaxHelp);
Match syntaxMatch = Syntax.Match(syntax);
if (!syntaxMatch.Success)
throw new SyntaxException(SyntaxHelp);
Condition condition = new Condition(syntaxMatch.Groups[1].Value,
syntaxMatch.Groups[2].Value, syntaxMatch.Groups[3].Value);
while (expressions.Any())
{
string @operator = expressions.Shift().Trim();
Match expressionMatch = Syntax.Match(expressions.Shift());
if (!expressionMatch.Success)
throw new SyntaxException(SyntaxHelp);
Condition newCondition = new Condition(expressionMatch.Groups[1].Value,
expressionMatch.Groups[2].Value, expressionMatch.Groups[3].Value);
switch (@operator)
{
case "and":
newCondition.And(condition);
break;
case "or":
newCondition.Or(condition);
break;
}
condition = newCondition;
}
block = condition;
}
Blocks.Add(block);
NodeList = block.Attach(new List<object>());
}