示例#1
0
        private static Dictionary <byte, NooliteSensorInfo> LoadConfig(INooliteSensorInfoRepository config)
        {
            Guard.DebugAssertArgumentNotNull(config, nameof(config));

            try
            {
                return(config.GetAll().Result.ToDictionary(cfg => cfg.Channel));
            }
            catch (ArgumentException ex)
            {
                throw new InvalidConfigurationException(ex, "Found duplicated Noolite sensor channels in the configuration file.");
            }
        }
示例#2
0
        public NooliteSensor(
            IEventSender eventSender,
            IRX2164Adapter adapter,
            INooliteSensorInfoRepository configuration,
            ILogger log)
        {
            Guard.DebugAssertArgumentNotNull(eventSender, nameof(eventSender));
            Guard.DebugAssertArgumentNotNull(adapter, nameof(adapter));
            Guard.DebugAssertArgumentNotNull(configuration, nameof(configuration));

            _eventSender     = eventSender;
            _adapter         = adapter;
            _log             = log;
            _channelToConfig = new Lazy <IDictionary <byte, NooliteSensorInfo> >(() => LoadConfig(configuration));
        }