Ejemplo n.º 1
0
        private void UpdateConfiguration(String configSource)
        {
            lock (configurationUpdateLock)
            {
                ConfigurationInstanceConfigurationAccessor updatedConfigurationAccessor
                    = new ConfigurationInstanceConfigurationAccessor(ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None));

                manageabilityHelper.UpdateConfigurationManageability(updatedConfigurationAccessor);

                List <String> sectionsToNotify = new List <String>();
                bool          notifyAll        = ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource.Equals(configSource);

                foreach (String sectionName in currentConfigurationAccessor.GetRequestedSectionNames())
                {
                    ConfigurationSection currentSection = currentConfigurationAccessor.GetSection(sectionName);
                    ConfigurationSection updatedSection = updatedConfigurationAccessor.GetSection(sectionName);

                    if (currentSection != null || updatedSection != null)
                    {
                        UpdateWatchers(currentSection, updatedSection);

                        // notify if:
                        // - instructed to notify all
                        // - any of the versions is null, or its config source matches the changed source
                        if (notifyAll ||
                            (updatedSection == null || configSource.Equals(updatedSection.SectionInformation.ConfigSource)) ||
                            (currentSection == null || configSource.Equals(currentSection.SectionInformation.ConfigSource)))
                        {
                            sectionsToNotify.Add(sectionName);
                        }
                    }
                }

                currentConfigurationAccessor = updatedConfigurationAccessor;
                notificationCoordinator.NotifyUpdatedSections(sectionsToNotify);
            }
        }
 private void UpdateConfiguration(string configSource)
 {
     lock (this.configurationUpdateLock)
     {
         ConfigurationInstanceConfigurationAccessor configurationAccessor = new ConfigurationInstanceConfigurationAccessor(ConfigurationManager.OpenMappedExeConfiguration(this.fileMap, ConfigurationUserLevel.None));
         this.manageabilityHelper.UpdateConfigurationManageability(configurationAccessor);
         List<string> sectionsToNotify = new List<string>();
         bool flag = "".Equals(configSource);
         foreach (string str in this.currentConfigurationAccessor.GetRequestedSectionNames())
         {
             ConfigurationSection currentSection = this.currentConfigurationAccessor.GetSection(str);
             ConfigurationSection section = configurationAccessor.GetSection(str);
             if ((currentSection != null) || (section != null))
             {
                 this.UpdateWatchers(currentSection, section);
                 if ((flag || (section == null)) || ((configSource.Equals(section.SectionInformation.ConfigSource) || (currentSection == null)) || configSource.Equals(currentSection.SectionInformation.ConfigSource)))
                 {
                     sectionsToNotify.Add(str);
                 }
             }
         }
         this.currentConfigurationAccessor = configurationAccessor;
         this.notificationCoordinator.NotifyUpdatedSections(sectionsToNotify);
     }
 }
        void UpdateConfiguration(String configSource)
        {
            lock (configurationUpdateLock)
            {
                ConfigurationInstanceConfigurationAccessor updatedConfigurationAccessor
                    = new ConfigurationInstanceConfigurationAccessor(ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None));

                manageabilityHelper.UpdateConfigurationManageability(updatedConfigurationAccessor);

                List<String> sectionsToNotify = new List<String>();
                bool notifyAll = ConfigurationChangeWatcherCoordinator.MainConfigurationFileSource.Equals(configSource);

                foreach (String sectionName in currentConfigurationAccessor.GetRequestedSectionNames())
                {
                    ConfigurationSection currentSection = currentConfigurationAccessor.GetSection(sectionName);
                    ConfigurationSection updatedSection = updatedConfigurationAccessor.GetSection(sectionName);

                    if (currentSection != null || updatedSection != null)
                    {
                        UpdateWatchers(currentSection, updatedSection);

                        // notify if:
                        // - instructed to notify all
                        // - any of the versions is null, or its config source matches the changed source
                        if (notifyAll
                            || (updatedSection == null || configSource.Equals(updatedSection.SectionInformation.ConfigSource))
                            || (currentSection == null || configSource.Equals(currentSection.SectionInformation.ConfigSource)))
                        {
                            sectionsToNotify.Add(sectionName);
                        }
                    }
                }

                currentConfigurationAccessor = updatedConfigurationAccessor;
                notificationCoordinator.NotifyUpdatedSections(sectionsToNotify);
            }
        }