Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void SaveCommandSavesTheHierarchy()
        {
            ConfigurationApplicationNode     node      = new ConfigurationApplicationNode(ConfigurationApplicationFile.FromCurrentAppDomain());
            IConfigurationUIHierarchy        hierarchy = new ConfigurationUIHierarchy(node, serviceProvider);
            IConfigurationUIHierarchyService service   = (IConfigurationUIHierarchyService)serviceProvider.GetService(typeof(IConfigurationUIHierarchyService));

            service.AddHierarchy(hierarchy);
            hierarchy.Saved += new EventHandler <HierarchySavedEventArgs>(OnHierarchySaved);
            SaveConfigurationApplicationNodeCommand cmd = new SaveConfigurationApplicationNodeCommand(serviceProvider);

            cmd.Execute(node);

            Assert.IsTrue(cmd.SaveSucceeded);
            Assert.IsTrue(saveCalled);
        }