/// <summary> /// Configures the <see cref="ILoggerRepository"/> for the specified assembly. /// </summary> /// <param name="assembly">The assembly that this attribute was defined on.</param> /// <param name="repository">The repository to configure.</param> /// <remarks> /// <para> /// Configure the repository using the <see cref="DOMConfigurator"/>. /// The <paramref name="repository"/> specified must extend the <see cref="Hierarchy"/> /// class otherwise the <see cref="DOMConfigurator"/> will not be able to /// configure it. /// </para> /// </remarks> /// <exception cref="ArgumentOutOfRangeException">The <paramref name="repository" /> does not extend <see cref="Hierarchy"/>.</exception> override public void Configure(Assembly assembly, ILoggerRepository repository) { // Ensure that the the repository extends the Hierarchy class if (!(repository is Hierarchy)) { throw new ArgumentOutOfRangeException("Parameter: repository Value: [" + repository + "] is out of range. DOMConfigurator can only configure Hierarchy objects"); } // Work out the full path to the config file string fullPath2ConfigFile = null; // Select the config file if (m_configFile == null || m_configFile.Length == 0) { if (m_configFileExtension == null || m_configFileExtension.Length == 0) { // Use the default .config file for the AppDomain fullPath2ConfigFile = SystemInfo.ConfigurationFileLocation; } else { // Force the extension to start with a '.' if (m_configFileExtension[0] != '.') { m_configFileExtension = "." + m_configFileExtension; } fullPath2ConfigFile = Path.Combine(SystemInfo.ApplicationBaseDirectory, SystemInfo.AssemblyFileName(assembly) + m_configFileExtension); } } else { // Just the base dir + the config file fullPath2ConfigFile = Path.Combine(SystemInfo.ApplicationBaseDirectory, m_configFile); } #if (SSCLI) DOMConfigurator.Configure(repository as Hierarchy, new FileInfo(fullPath2ConfigFile)); #else // Do we configure just once or do we configure and then watch? if (m_configureAndWatch) { DOMConfigurator.ConfigureAndWatch(repository as Hierarchy, new FileInfo(fullPath2ConfigFile)); } else { DOMConfigurator.Configure(repository as Hierarchy, new FileInfo(fullPath2ConfigFile)); } #endif }
/// <summary> /// Called by the timer when the configuration has been updated. /// </summary> /// <param name="state">null</param> private void OnWhatchedFileChange(object state) { DOMConfigurator.Configure(m_repository, m_configFile); }