WithRelatedCondition() public method

public WithRelatedCondition ( ConditionRelation relation, Condition condition ) : Condition
relation ConditionRelation
condition Condition
return Condition
コード例 #1
0
        public static TurnOnAndOffAutomation WithTurnOnIfAllRollerShuttersClosed(this TurnOnAndOffAutomation automation, params IRollerShutter[] rollerShutters)
        {
            if (automation == null) throw new ArgumentNullException(nameof(automation));
            if (rollerShutters == null) throw new ArgumentNullException(nameof(rollerShutters));

            var condition = new Condition().WithExpression(() => rollerShutters.First().IsClosed);
            foreach (var otherRollerShutter in rollerShutters.Skip(1))
            {
                condition.WithRelatedCondition(ConditionRelation.And, new Condition().WithExpression(() => otherRollerShutter.IsClosed));
            }

            return automation.WithEnablingCondition(ConditionRelation.Or, condition);
        }