Exemple #1
0
        public GroupService(Config config, LightService lightService)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (lightService is null)
            {
                throw new ArgumentNullException(nameof(lightService));
            }

            this.lightService = lightService;
            this.nameToGroup  = new Dictionary <string, Group>();
            this.groupValues  = new Dictionary <Group, int>();
            this.groupToLamps = new Dictionary <Group, IEnumerable <string> >();

            foreach (var group in config.Groups)
            {
                nameToGroup[group.Name] = group;
                groupValues[group]      = group.Percentage;
                foreach (var lamp in group.Lamps)
                {
                    if (lightService.IsNameExisting(lamp))
                    {
                        lightService.UpdateFactor(lamp, group.Percentage / 100d, 1);
                    }
                }
            }

            foreach (var group in config.Groups)
            {
                groupToLamps[group] = GetLampsInGroupHelper(group.Name, new List <string>()).Distinct();
            }
        }
Exemple #2
0
        public PresetService(Models.Config config, GroupService groupService, LightService lightService)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            this.groupService = groupService;
            this.lightService = lightService;
            this.tokenSource  = new CancellationTokenSource();
            this.nameToPreset = new Dictionary <string, Preset>();

            LoadPresetNames(config);
            ActivateDefaultPreset(config);
        }