@@ -44,72 +44,35 @@ public IEnumerable<RuleSpecification> GetRulesSpecifications()
4444 return rulesSpecifications ;
4545 }
4646
47- private static RuleBuilderResult < ContentTypes , ConditionTypes > CreateMultipleRule ( ContentTypes contentTypes , int value , DateTime dateBegin ,
48- DateTime ? dateEnd , bool isActive = true ) =>
49- RuleBuilder
50- . NewRule < ContentTypes , ConditionTypes > ( )
51- . WithName ( $ "Multi rule for test { contentTypes } { value } ")
52- . WithContent ( contentTypes , new { Value = value } )
53- . WithDatesInterval ( dateBegin , dateEnd )
54- . WithActive ( isActive )
55- . WithCondition ( cnb => cnb . AsComposed ( )
56- . WithLogicalOperator ( LogicalOperators . Or )
57- . AddCondition ( condition => condition
58- . AsValued ( ConditionTypes . RoyalNumber ) . OfDataType < int > ( )
59- . WithComparisonOperator ( Operators . Equal )
60- . SetOperand ( 7 )
61- . Build ( ) )
62- . AddCondition ( condition => condition
63- . AsValued ( ConditionTypes . SumAll ) . OfDataType < IEnumerable < int > > ( )
64- . WithComparisonOperator ( Operators . In )
65- . SetOperand ( new int [ ] { 9 , 8 , 6 } )
66- . Build ( ) )
67- . AddCondition ( condition => condition . AsComposed ( )
68- . WithLogicalOperator ( LogicalOperators . And )
69- . AddCondition ( sub => sub
70- . AsValued ( ConditionTypes . IsPrimeNumber ) . OfDataType < bool > ( )
71- . WithComparisonOperator ( Operators . Equal )
72- . SetOperand ( false )
73- . Build ( ) )
74- . AddCondition ( sub => sub
75- . AsValued ( ConditionTypes . SumAll ) . OfDataType < string > ( )
76- . WithComparisonOperator ( Operators . StartsWith )
77- . SetOperand ( "15" )
78- . Build ( ) )
79- . AddCondition ( condition => condition . AsComposed ( )
80- . WithLogicalOperator ( LogicalOperators . And )
81- . AddCondition ( sub => sub
82- . AsValued ( ConditionTypes . CanNumberBeDividedBy3 ) . OfDataType < bool > ( )
83- . WithComparisonOperator ( Operators . Equal )
84- . SetOperand ( false )
85- . Build ( ) )
86- . AddCondition ( sub => sub
87- . AsValued ( ConditionTypes . SumAll ) . OfDataType < string > ( )
88- . WithComparisonOperator ( Operators . NotEqual )
89- . SetOperand ( string . Empty )
90- . Build ( ) )
91- . Build ( ) )
92- . Build ( ) )
93- . AddCondition ( condition => condition . AsComposed ( )
94- . WithLogicalOperator ( LogicalOperators . And )
95- . AddCondition ( sub => sub
96- . AsValued ( ConditionTypes . IsPrimeNumber ) . OfDataType < bool > ( )
97- . WithComparisonOperator ( Operators . Equal )
98- . SetOperand ( true )
99- . Build ( ) )
100- . AddCondition ( sub => sub
101- . AsValued ( ConditionTypes . SumAll ) . OfDataType < string > ( )
102- . WithComparisonOperator ( Operators . StartsWith )
103- . SetOperand ( "5" )
104- . Build ( ) )
105- . AddCondition ( sub => sub
106- . AsValued ( ConditionTypes . CanNumberBeDividedBy3 ) . OfDataType < bool > ( )
107- . WithComparisonOperator ( Operators . Equal )
108- . SetOperand ( false )
109- . Build ( ) )
110- . Build ( ) )
111- . Build ( ) )
112- . Build ( ) ;
47+ private static RuleBuilderResult < ContentTypes , ConditionTypes > CreateMultipleRule (
48+ ContentTypes contentTypes ,
49+ int value ,
50+ DateTime dateBegin ,
51+ DateTime ? dateEnd ,
52+ bool isActive = true ) => RuleBuilder
53+ . NewRule < ContentTypes , ConditionTypes > ( )
54+ . WithName ( $ "Multi rule for test { contentTypes } { value } ")
55+ . WithContent ( contentTypes , new { Value = value } )
56+ . WithDatesInterval ( dateBegin , dateEnd )
57+ . WithActive ( isActive )
58+ . WithCondition ( rootCond => rootCond
59+ . Or ( o => o
60+ . Value ( ConditionTypes . RoyalNumber , Operators . Equal , 7 )
61+ . Value ( ConditionTypes . SumAll , Operators . In , new int [ ] { 9 , 8 , 6 } )
62+ . And ( a => a
63+ . Value ( ConditionTypes . IsPrimeNumber , Operators . Equal , false )
64+ . Value ( ConditionTypes . SumAll , Operators . StartsWith , "15" )
65+ )
66+ . And ( a => a
67+ . Value ( ConditionTypes . CanNumberBeDividedBy3 , Operators . Equal , false )
68+ . Value ( ConditionTypes . SumAll , Operators . NotEqual , string . Empty )
69+ )
70+ . And ( a => a
71+ . Value ( ConditionTypes . IsPrimeNumber , Operators . Equal , true )
72+ . Value ( ConditionTypes . SumAll , Operators . StartsWith , "5" )
73+ . Value ( ConditionTypes . CanNumberBeDividedBy3 , Operators . Equal , false )
74+ ) ) )
75+ . Build ( ) ;
11376
11477 private void Add (
11578 RuleBuilderResult < ContentTypes , ConditionTypes > rule ,
@@ -134,4 +97,4 @@ private DateTime CreateRandomDateBegin(int year)
13497 return dateBegin . AddMonths ( months ) . AddDays ( 1 ) ;
13598 }
13699 }
137- }
100+ }
0 commit comments