Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="configurationFile"></param>
        public void Load(string configurationFile)
        {
            loading = true;
            try
            {
                FileConfigurationSource.ResetImplementation(configurationFile, false);

                IConfigurationUIHierarchyService hierarchyService = (IConfigurationUIHierarchyService)serviceProvider.GetService(typeof(IConfigurationUIHierarchyService));

                foreach (ConfigurationUIHierarchy hierarchy in hierarchyService.GetAllHierarchies())
                {
                    hierarchyService.RemoveHierarchy(hierarchy);
                }

                ConfigurationApplicationFile data         = new ConfigurationApplicationFile(Path.GetDirectoryName(configurationFile), configurationFile);
                ConfigurationUIHierarchy     newhierarchy = new ConfigurationUIHierarchy(new ConfigurationApplicationNode(data), serviceProvider);
                hierarchyService.AddHierarchy(newhierarchy);
                hierarchyService.SelectedHierarchy = newhierarchy;

                configurationEditor.SetMainHierarchy(newhierarchy);
                newhierarchy.Open();
                configurationEditor.ClearDirtyState();
            }
            finally
            {
                loading = false;
            }
        }
Пример #2
0
        private ConfigurationUIHierarchy LoadMainConfiguration(string configurationFile, IServiceProvider serviceProvider)
        {
            IConfigurationUIHierarchyService hierarchyService = (IConfigurationUIHierarchyService)serviceProvider.GetService(typeof(IConfigurationUIHierarchyService));

            ConfigurationApplicationFile data      = new ConfigurationApplicationFile(Path.GetDirectoryName(configurationFile), configurationFile);
            ConfigurationUIHierarchy     hierarchy = new ConfigurationUIHierarchy(new ConfigurationApplicationNode(data), serviceProvider);

            hierarchyService.AddHierarchy(hierarchy);
            hierarchyService.SelectedHierarchy = hierarchy;

            hierarchy.Open();
            return(hierarchy);
        }