private void Initialize() { // CCU, Out-of-Rotation var allControllers = GetNonConfigurableControllers(this.maxCcu); // try to load feedback controllers from file: string message; FeedbackControlSystemSection section; string filename = Path.Combine(this.applicationRootPath, GameServerSettings.Default.WorkloadConfigFile); if (!ConfigurationLoader.TryLoadFromFile(filename, out section, out message)) { log.WarnFormat( "Could not initialize Feedback Control System from configuration: Invalid configuration file {0}. Using default settings... ({1})", filename, message); } if (section != null) { // load controllers from config file.); foreach (FeedbackControllerElement controllerElement in section.FeedbackControllers) { var dict = new Dictionary <FeedbackLevel, int>(); foreach (FeedbackLevelElement level in controllerElement.Levels) { dict.Add(level.Level, level.Value); } var controller = new FeedbackController(controllerElement.Name, dict, controllerElement.InitialInput, controllerElement.InitialLevel); allControllers.Add(controller); } log.InfoFormat("Initialized FeedbackControlSystem with {0} controllers from config file.", section.FeedbackControllers.Count); } else { // default settings, in case no config file was found. allControllers.AddRange(DefaultConfiguration.GetDefaultControllers()); } this.controllerCollection = new FeedbackControllerCollection(allControllers.ToArray()); }
private void Initialize() { string message; FeedbackControlSystemSection section; string filename = Path.Combine(this.applicationRootPath, GameServerSettings.Default.WorkloadConfigFile); // CCU, Out-of-Rotation var allControllers = GetNonConfigurableControllers(this.maxCcu); if (!ConfigurationLoader.TryLoadFromFile(filename, out section, out message)) { log.WarnFormat( "Could not initialize Feedback Control System from configuration: Invalid configuration file {0}. Using default settings... ({1})", filename, message); } if (section != null) { // load controllers from config file.); foreach (FeedbackControllerElement controllerElement in section.FeedbackControllers) { var dict = new Dictionary<FeedbackLevel, int>(); foreach (FeedbackLevelElement level in controllerElement.Levels) { dict.Add(level.Level, level.Value); } var controller = new FeedbackController(controllerElement.Name, dict, controllerElement.InitialInput, controllerElement.InitialLevel); allControllers.Add(controller); } log.InfoFormat("Initialized FeedbackControlSystem with {0} controllers from config file.", section.FeedbackControllers.Count); } else { // default settings, in case no config file was found. allControllers.AddRange(DefaultConfiguration.GetDefaultControllers()); } this.controllerCollection = new FeedbackControllerCollection(allControllers.ToArray()); }