コード例 #1
0
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(TurnOnSlow);
            _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout);

            return(this);
        }
コード例 #2
0
        public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(ExecuteAutoTrigger);
            _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout);

            _settingsService.CreateSettingsMonitor <MotionDetectorSettings>(motionDetector, CancelTimeoutIfMotionDetectorDeactivated);

            return(this);
        }
コード例 #3
0
        public static ITrigger CreatePressedLongTrigger(this IButton button, IMessageBrokerService messageBroker)
        {
            if (button == null)
            {
                throw new ArgumentNullException(nameof(button));
            }
            if (messageBroker == null)
            {
                throw new ArgumentNullException(nameof(messageBroker));
            }

            return(messageBroker.CreateTrigger <ButtonPressedLongEvent>(button.Id));
        }