Logical AND - true if ALL conditions are true.
Наследование: ConditionSet
Пример #1
0
        static ConditionSet ExportConditions( GroupNode node )
        {
            ConditionSet set;
            switch( node.Op ) {
                case GroupNodeType.AND:
                    set = new ConditionAND();
                    break;
                case GroupNodeType.OR:
                    set = new ConditionOR();
                    break;
                case GroupNodeType.NAND:
                    set = new ConditionNAND();
                    break;
                case GroupNodeType.NOR:
                    set = new ConditionNOR();
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            foreach( TreeNode subNode in node.Nodes ) {
                if( subNode is GroupNode ) {
                    set.Add( ExportConditions( (GroupNode)subNode ) );

                } else if( subNode is ConditionNode ) {
                    ConditionNode sn = (ConditionNode)subNode;
                    ConditionIntRange cond = new ConditionIntRange {
                        Comparison = sn.Op,
                        Field = sn.Field,
                        Value = sn.Value
                    };
                    set.Add( cond );

                } else {
                    throw new Exception();
                }
            }

            return set;
        }
Пример #2
0
        public Criterion(XElement el)
        {
            if (el == null)
            {
                throw new ArgumentNullException("el");
            }
            Type = (CriterionType)Enum.Parse(typeof(CriterionType), el.Attribute("type").Value, true);

            FromRank = RankManager.ParseRank(el.Attribute("fromRank").Value);
            if (FromRank == null)
            {
                throw new FormatException("Could not parse \"fromRank\"");
            }

            ToRank = RankManager.ParseRank(el.Attribute("toRank").Value);
            if (ToRank == null)
            {
                throw new FormatException("Could not parse \"toRank\"");
            }

            if (el.Elements().Count() == 1)
            {
                Condition = Condition.Parse(el.Elements().First());
            }
            else if (el.Elements().Count() > 1)
            {
                ConditionAND cand = new ConditionAND();
                foreach (XElement cond in el.Elements())
                {
                    cand.Add(Condition.Parse(cond));
                }
                Condition = cand;
            }
            else
            {
                throw new FormatException("At least one condition required.");
            }
        }
Пример #3
0
        public Criterion( XElement el ) {
            if( el == null ) throw new ArgumentNullException( "el" );
            Type = (CriterionType)Enum.Parse( typeof( CriterionType ), el.Attribute( "type" ).Value, true );

            FromRank = RankManager.ParseRank( el.Attribute( "fromRank" ).Value );
            if( FromRank == null ) throw new FormatException( "Could not parse \"fromRank\"" );

            ToRank = RankManager.ParseRank( el.Attribute( "toRank" ).Value );
            if( ToRank == null ) throw new FormatException( "Could not parse \"toRank\"" );

            if( el.Elements().Count() == 1 ) {
                Condition = Condition.Parse( el.Elements().First() );

            } else if( el.Elements().Count() > 1 ) {
                ConditionAND cand = new ConditionAND();
                foreach( XElement cond in el.Elements() ) {
                    cand.Add( Condition.Parse( cond ) );
                }
                Condition = cand;

            } else {
                throw new FormatException( "At least one condition required." );
            }
        }