示例#1
0
        /// <summary>
        /// Closes the application configuration.
        /// </summary>
        /// <param name="node">
        /// The node to execute the command upon.
        /// </param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            try
            {
                UIService.BeginUpdate();

                if (UIService.IsDirty(node.Hierarchy))
                {
                    DialogResult result = UIService.ShowMessage(Resources.SaveApplicationRequest, Resources.SaveApplicationCaption, MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        if (!TryAndSaveApplication(node))
                        {
                            return;
                        }
                    }
                }
                if (ErrorLogService.ConfigurationErrorCount > 0)
                {
                    UIService.DisplayErrorLog(ErrorLogService);
                    DialogResult result = UIService.ShowMessage(Resources.SaveApplicationErrorRequestMessage, Resources.SaveApplicationCaption, MessageBoxButtons.YesNo);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }
                ConfigurationUIHierarchyService.RemoveHierarchy(node.Hierarchy.Id);
            }
            finally
            {
                UIService.EndUpdate();
            }
        }
示例#2
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();
     }
 }
示例#3
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();
            }
        }
示例#5
0
        public ServiceContainer Build()
        {
            ServiceContainer container = new ServiceContainer();
            NodeNameCreationService nodeNameCreationService = new NodeNameCreationService();
            ConfigurationUIHierarchyService configurationUIHierarchy = new ConfigurationUIHierarchyService();

            container.AddService(typeof(INodeNameCreationService), nodeNameCreationService);
            container.AddService(typeof(IConfigurationUIHierarchyService), configurationUIHierarchy);
            container.AddService(typeof(IUIService), this);
            container.AddService(typeof(IErrorLogService), new ErrorLogService());
            container.AddService(typeof(INodeCreationService), new NodeCreationService());
            container.AddService(typeof(IUICommandService), new UICommandService(configurationUIHierarchy));
            return container;
        }