Example #1
0
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         ConfigurationApplicationNode appNode   = new ConfigurationApplicationNode(applicationData);
         IConfigurationUIHierarchy    hierarchy = new ConfigurationUIHierarchy(appNode, ServiceProvider);
         ConfigurationUIHierarchyService.AddHierarchy(hierarchy);
         hierarchy.Load();
         UIService.SetUIDirty(hierarchy);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
Example #2
0
        private void OpenFile(ConfigurationNode node)
        {
            string fileToOpen = file;

            if (!Path.IsPathRooted(file))
            {
                string dir = Directory.GetCurrentDirectory();
                fileToOpen = Path.Combine(dir, file);
            }
            if (!File.Exists(file))
            {
                ServiceHelper.LogError(ServiceProvider, new ConfigurationError(node, string.Format(CultureInfo.CurrentCulture, Resources.ErrorFileCouldNotBeOpened, file)));
                return;
            }
            ConfigurationApplicationFile data      = new ConfigurationApplicationFile(Path.GetDirectoryName(fileToOpen), fileToOpen);
            IConfigurationUIHierarchy    hierarchy = new ConfigurationUIHierarchy(new ConfigurationApplicationNode(data), ServiceProvider);

            ConfigurationUIHierarchyService.AddHierarchy(hierarchy);
            hierarchy.Open();
        }
        private void OpenFile()
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter           = Resources.ConfigurationFileDialogFilter;
            fileDialog.CheckFileExists  = true;
            fileDialog.CheckPathExists  = true;
            fileDialog.AddExtension     = true;
            fileDialog.DefaultExt       = ".config";
            fileDialog.RestoreDirectory = true;
            DialogResult result = UIService.ShowOpenDialog(fileDialog);

            if (result == DialogResult.OK)
            {
                string file = fileDialog.FileName;
                ConfigurationApplicationFile data      = new ConfigurationApplicationFile(Path.GetDirectoryName(file), file);
                IConfigurationUIHierarchy    hierarchy = new ConfigurationUIHierarchy(new ConfigurationApplicationNode(data), ServiceProvider);
                ConfigurationUIHierarchyService.AddHierarchy(hierarchy);
                hierarchy.Open();
            }
        }