/// <summary> /// <para>Executed upon instantiation of all program Managers.</para> /// <para>Registers all IManagers in the specified list implementing IConfigurable.</para> /// </summary> /// <exception cref="ConfigurationRegistrationException">Thrown when an error is encountered during setup.</exception> protected override void Setup() { logger.EnterMethod(); logger.Debug("Performing Setup for '" + GetType().Name + "'..."); IReadOnlyList <IManager> managerInstances = Dependency <IApplicationManager>().Managers; List <Type> managerTypes = managerInstances.Select(m => m.GetType()).ToList(); logger.Info("Registering Managers with the Configuration Manager..."); IResult registerResult = ConfigurableTypeRegistry.RegisterTypes(managerTypes); if (registerResult.ResultCode == ResultCode.Failure) { throw new ConfigurationRegistrationException("Error registering Manager Types: " + registerResult.GetLastError()); } logger.ExitMethod(); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigurationManager"/> class. /// </summary> /// <remarks> /// This constructor is marked private and is intended to be called from the /// <see cref="Instantiate(IApplicationManager, IPlatformManager)"/> method exclusively in order to implement the /// Singleton design pattern. /// </remarks> /// <param name="manager">The ApplicationManager instance for the application.</param> /// <param name="platformManager">The PlatformManager instance for the application.</param> private ConfigurationManager(IApplicationManager manager, IPlatformManager platformManager) { base.logger = logger; logger.EnterMethod(); ManagerName = "Configuration Manager"; // register dependencies RegisterDependency <IApplicationManager>(manager); RegisterDependency <IPlatformManager>(platformManager); Settings = new ConfigurationSettings(); ConfigurableTypeRegistry = new ConfigurableTypeRegistry(); Configuration = new Configuration(ConfigurableTypeRegistry); ConfigurationLoader = new ConfigurationLoader(Dependency <IPlatformManager>().Platform); ChangeState(State.Initialized); logger.ExitMethod(); }