PredicateBuilder.and_safe factory method (handles null args gracefully)
This commit is contained in:
1 parent
6f68c0f6a1
commit
0fb69c8beb
1 file changed
+8
@@ -74,6 +74,14 @@ namespace mbts {
|
||||
public static IPredicate<T> not_in_set<T>(ISet<T> set) =>
|
||||
in_set(set).negate();
|
||||
|
||||
public static IPredicate<T> and_safe<T>(this IPredicate<T> first, IPredicate<T> second) {
|
||||
if (first == null)
|
||||
return second;
|
||||
if (second == null)
|
||||
return first;
|
||||
return and<T>(first, second);
|
||||
}
|
||||
|
||||
public static IPredicate<T> and<T>(this IPredicate<T> first, IPredicate<T> second) =>
|
||||
new AndTrigger<T>(first, second);
|
||||
|
||||
|
||||
Reference in new issue
Block a user