当前位置: 首页>>代码示例>>C#>>正文


C# Condition.Or方法代码示例

本文整理汇总了C#中Condition.Or方法的典型用法代码示例。如果您正苦于以下问题:C# Condition.Or方法的具体用法?C# Condition.Or怎么用?C# Condition.Or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Condition的用法示例。


在下文中一共展示了Condition.Or方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:gmanny,项目名称:DotLiquid.Modules,代码行数:39,代码来源:Section.cs

示例2: TestOrCondition

		public void TestOrCondition()
		{
			Condition condition = new Condition("1", "==", "2");
			Assert.IsFalse(condition.Evaluate(null));

			condition.Or(new Condition("2", "==", "1"));
			Assert.IsFalse(condition.Evaluate(null));

			condition.Or(new Condition("1", "==", "1"));
			Assert.IsTrue(condition.Evaluate(null));
		}
开发者ID:nZeus,项目名称:dotliquid,代码行数:11,代码来源:ConditionTests.cs

示例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>());
        }
开发者ID:Elph,项目名称:dotliquid,代码行数:51,代码来源:If.cs

示例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>());
        }
开发者ID:tt,项目名称:dotliquid,代码行数:48,代码来源:If.cs


注:本文中的Condition.Or方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。