private static IDesignConfigurationSource GetSectionSource(IDesignConfigurationSource mainConfigurationSource)
        {
            var configSourceSection =
                mainConfigurationSource.GetLocalSection(ConfigurationSourceSection.SectionName) as ConfigurationSourceSection;

            return(GetSelectedConfigSource(configSourceSection, mainConfigurationSource));
        }
        public bool Load(IDesignConfigurationSource configSource)
        {
            Clear();
            Initialize();

            IDesignConfigurationSource sectionConfigurationSource = null;

            try
            {
                sectionConfigurationSource = GetSectionSource(configSource);
            }
            catch (Exception ex)
            {
                ConfigurationLogWriter.LogException(ex);
                uiService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLoadingConfigSourceFile, ex.Message),
                                         Resources.ErrorTitle,
                                         MessageBoxButton.OK);
                return(false);
            }

            if (sectionConfigurationSource != null)
            {
                try
                {
                    AddSection(ConfigurationSourceSection.SectionName,
                               configSource.GetLocalSection(ConfigurationSourceSection.SectionName),
                               new InitializeContext(configSource));

                    LoadSectionsFromSource(sectionConfigurationSource);
                }
                catch
                {
                    var disposable = sectionConfigurationSource as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }

                    throw;
                }
            }
            else
            {
                LoadSectionsFromSource(configSource);
            }


            Validate();

            return(true);
        }
        private void LoadSectionsFromSource(IDesignConfigurationSource sectionConfigurationSource)
        {
            var locator = builder.Resolve <ConfigurationSectionLocator>();

            foreach (var sectionName in locator.ConfigurationSectionNames)
            {
                try
                {
                    var section = sectionConfigurationSource.GetLocalSection(sectionName);
                    if (section != null)
                    {
                        AddSection(sectionName, section, new InitializeContext(sectionConfigurationSource));
                    }
                }
                catch (Exception e)
                {
                    uiService.ShowError(e, string.Format(CultureInfo.CurrentCulture, Resources.ErrorCouldNotLoadSection, sectionName));
                }
            }
        }
        public bool Load(IDesignConfigurationSource configSource)
        {
            Clear();
            Initialize();

            IDesignConfigurationSource sectionConfigurationSource = null;
            try
            {
                sectionConfigurationSource = GetSectionSource(configSource);
            }
            catch (Exception ex)
            {
                ConfigurationLogWriter.LogException(ex);
                uiService.ShowMessageWpf(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLoadingConfigSourceFile, ex.Message),
                                            Resources.ErrorTitle,
                                         MessageBoxButton.OK);
                return false;
            }

            if (sectionConfigurationSource != null)
            {
                try
                {
                    AddSection(ConfigurationSourceSection.SectionName,
                               configSource.GetLocalSection(ConfigurationSourceSection.SectionName),
                               new InitializeContext(configSource));

                    LoadSectionsFromSource(sectionConfigurationSource);
                }
                catch
                {
                    var disposable = sectionConfigurationSource as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }

                    throw;
                }
            }
            else
            {
                LoadSectionsFromSource(configSource);
            }


            Validate();

            return true;
        }
        private static IDesignConfigurationSource GetSectionSource(IDesignConfigurationSource mainConfigurationSource)
        {
            var configSourceSection =
                mainConfigurationSource.GetLocalSection(ConfigurationSourceSection.SectionName) as ConfigurationSourceSection;

            return GetSelectedConfigSource(configSourceSection, mainConfigurationSource);
        }
 private void LoadSectionsFromSource(IDesignConfigurationSource sectionConfigurationSource)
 {
     var locator = builder.Resolve<ConfigurationSectionLocator>();
     foreach (var sectionName in locator.ConfigurationSectionNames)
     {
         try
         {
             var section = sectionConfigurationSource.GetLocalSection(sectionName);
             if (section != null)
             {
                 AddSection(sectionName, section, new InitializeContext(sectionConfigurationSource));
             }
         }
         catch (Exception e)
         {
             uiService.ShowError(e, string.Format(CultureInfo.CurrentCulture, Resources.ErrorCouldNotLoadSection, sectionName));
         }
     }
 }