@@ -181,11 +181,13 @@ void SetUpdateNotificationPage()
181181 }
182182
183183 /// <summary>
184- /// ExcludesAnyOf() implements A != a OR B != b AND ...
185- /// ExcludesAllOf() implements A != a AND B != b AND ...
186- /// IncludesAnyOf() implements D == d OR E == e OR ...
187- /// IncludesAllOf() implements D == d AND E == e OR ...
188184 /// CheckConstraints() implements ExcludesAnyOf() AND ExcludesAllOf() AND IncludesAnyOf() AND IncludesAllOf(), but all parts are optional.
185+ /// Consider first the Excludes:
186+ /// ExcludesAnyOf() Unmet if A == a OR B == b OR ...
187+ /// ExcludesAllOf() Unmet if A == a AND B == b AND ...
188+ /// and then the Includes:
189+ /// IncludesAnyOf() Met if D == d OR E == e OR ...
190+ /// IncludesAllOf() Met if D == d AND E == e OR ...
189191 /// </summary>
190192 /// <param name="page"></param>
191193 /// <param name="n"></param>
@@ -197,10 +199,10 @@ private void CheckConstraints(NotificationPage page, Notification n)
197199 var c = Notifications . CheckList . Where ( check => check . Id == nc . Id ) . FirstOrDefault ( ) ;
198200 if ( c != null )
199201 {
200- // Check the ALL constraints
202+ // Check the Excludes constraints first
201203 if ( c . ExcludesAllOf != null ) // ExcludesAllOf is optional
202204 {
203- var checkFailed = CheckMatch ( c , c . ExcludesAllOf ) ;
205+ var checkFailed = CheckMissingMatch ( c , c . ExcludesAllOf ) ;
204206 if ( checkFailed != null )
205207 {
206208 foreach ( var item in checkFailed . UnmetItemList )
@@ -210,25 +212,9 @@ private void CheckConstraints(NotificationPage page, Notification n)
210212 return ;
211213 }
212214 }
213-
214- // NOT TESTED YET
215- //if (c.IncludesAllOf != null) // IncludesAllOf is optional
216- //{
217- // var checkFailed = CheckAll(c, c.IncludesAllOf);
218- // if (checkFailed != null)
219- // {
220- // foreach (var item in checkFailed.UnmetItemList)
221- // {
222- // AddItemToPage(page, item);
223- // }
224- // return;
225- // }
226- //}
227-
228- // Check the ANY constraints
229- if ( c . ExcludesAnyOf != null ) // ExcludesAnyOf is optional
215+ if ( c . ExcludesAnyOf ? . Count > 0 ) // ExcludesAnyOf is optional
230216 {
231- if ( CheckMatch ( c , c . ExcludesAnyOf ) != null )
217+ if ( CheckAnyMatch ( c , c . ExcludesAnyOf ) != null )
232218 {
233219 foreach ( var item in c . UnmetItemList )
234220 {
@@ -238,9 +224,22 @@ private void CheckConstraints(NotificationPage page, Notification n)
238224 }
239225 }
240226
241- if ( c . IncludesAnyOf != null ) // IncludesAnyOf is optional
227+ // Check the Includes constraints last
228+ if ( c . IncludesAllOf ? . Count > 0 ) // IncludesAllOf is optional
229+ {
230+ var checkFailed = CheckMissingMatch ( c , c . IncludesAllOf ) ;
231+ if ( checkFailed != null )
232+ {
233+ foreach ( var item in checkFailed . UnmetItemList )
234+ {
235+ AddItemToPage ( page , item ) ;
236+ }
237+ return ;
238+ }
239+ }
240+ if ( c . IncludesAnyOf ? . Count > 0 ) // IncludesAnyOf is optional
242241 {
243- if ( CheckMatch ( c , c . IncludesAnyOf ) == null )
242+ if ( CheckAnyMatch ( c , c . IncludesAnyOf ) == null )
244243 {
245244 foreach ( var item in c . UnmetItemList )
246245 {
@@ -286,7 +285,7 @@ private void AddItemToPage(NotificationPage page, Item item)
286285 /// </summary>
287286 /// <param name="check"></param>
288287 /// <returns></returns>
289- private Check CheckMatch ( Check check , List < Criteria > criteriaList )
288+ private Check CheckAnyMatch ( Check check , List < Criteria > criteriaList )
290289 {
291290 foreach ( var c in criteriaList )
292291 {
@@ -305,7 +304,7 @@ private Check CheckMatch(Check check, List<Criteria> criteriaList)
305304 /// </summary>
306305 /// <param name="check"></param>
307306 /// <returns></returns>
308- private Check CheckNoMatch ( Check check , List < Criteria > criteriaList )
307+ private Check CheckMissingMatch ( Check check , List < Criteria > criteriaList )
309308 {
310309 foreach ( var c in criteriaList )
311310 {
0 commit comments