The code has been updated to improve the performance:
public static bool DoSequenceOfOr(params Func<bool>[] sequenceOfBooleanValue)
{
foreach (Func<bool> item in sequenceOfBooleanValue)
if (item())
return true;
return false;
}
public static bool DoSequenceOfAnd(params Func<bool>[] sequenceOfBooleanValue)
{
foreach (Func<bool> item in sequenceOfBooleanValue)
if (!item())
return default(bool);
return true;
}
Usage:
bool result1 = Operation.DoSequenceOfAnd(MethodOne, MethodTwo, MethodThree)
bool result2 = Operation.DoSequenceOfOr(MethodOne, MethodTwo, MethodThree)