Exemple #1
0
 public OutputsModule(GlobalConfig config)
 {
     Get["/outputs"] = _ =>
     {
         return config.OutputModules.Select(o => new {o.Key, o.Name});
     };
 }
        public override async Task<InitializationResult> Initialize()
        {
            globalConfig = await configurationCaretaker.Load();

            var outputDevices = new List<IOutputDevice>(globalConfig.OutputDevices);

            foreach (var outputModule in globalConfig.OutputModules)
            {
                var moduleConfig = globalConfig.OutputConfigurations.SingleOrDefault(c => c.Key == outputModule.Key);
                if (moduleConfig == null)
                {
                    moduleConfig = outputConfigurations[outputModule.Key];
                    globalConfig.OutputConfigurations.Add(moduleConfig);
                }

                var profileManager = profileManagers[outputModule.Key];
                await profileManager.SetTarget(moduleConfig, mediator);

                var deviceManager = deviceManagers[outputModule.Key];
                deviceManager.SetTarget(moduleConfig);

                var moduleViewModel = new ModuleViewModel(outputModule.Name, profileManager, deviceManager, null);
                Modules.Add(moduleViewModel);

                var unconfiguredDevices = moduleConfig.OutputDevices.Where(d => outputDevices.All(od => od.Id != d.Id));
                globalConfig.OutputDevices.AddRange(unconfiguredDevices);
            }

            foreach (var inputModule in globalConfig.InputModules)
            {
                var moduleConfig = globalConfig.InputConfigurations.SingleOrDefault(c => c.Key == inputModule.Key);
                if (moduleConfig == null)
                {
                    moduleConfig = inputConfigurations[inputModule.Key];
                    globalConfig.InputConfigurations.Add(moduleConfig);
                }

                var profileManager = profileManagers[inputModule.Key];
                await profileManager.SetTarget(moduleConfig, mediator);

                var deviceManager = deviceManagers[inputModule.Key];
                deviceManager.SetTarget(moduleConfig);
               
                var inputSelector = inputSelectors[inputModule.Key];
                
                var moduleViewModel = new ModuleViewModel(inputModule.Name, profileManager, deviceManager, inputSelector);
                Modules.Add(moduleViewModel);
            }

            foreach (var outputDevice in globalConfig.OutputDevices)
            {
                var moduleConfiguration = globalConfig.OutputConfigurations.SingleOrDefault(c => c.Key.Equals(outputDevice.Type, StringComparison.OrdinalIgnoreCase));
                AddActiveDevice(moduleConfiguration, outputDevice);
            }
            
            return InitializationResult.Succeeded;
        }
Exemple #3
0
 public ConfigBuilder()
 {
     config = new GlobalConfig();
 }
Exemple #4
0
        //private NancyHost nancyHost;

        public EmanateService(GlobalConfig config, IIndex<string, IBuildMonitorFactory> buildMonitorFactories)
        {
            this.config = config;
            this.buildMonitorFactories = buildMonitorFactories;
        }