Example #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();
            }
        }
Example #2
0
 /// <summary>
 /// Removes the node from the <see cref="IConfigurationUIHierarchy"/>.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         UIService.SetUIDirty(node.Hierarchy);
         node.Remove();
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
 /// <summary>
 /// <para>Creates a new <see cref="ApplicationConfigurationNode"/> object and adds it to the solution.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The <see cref="ApplicationConfigurationNode"/> is the root of an <see cref="IUIHierarchy"/> so the <paramref name="node"/> is not used, so passing <see langword="null"/> is expected.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         ApplicationConfigurationNode appNode = new ApplicationConfigurationNode(applicationData);
         IUIHierarchy hierarchy = ConfigurationUIHierarchyFactory.Create(appNode, ServiceProvider);
         UIHierarchyService.AddHierarchy(hierarchy);
         UIService.SetUIDirty(hierarchy);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
 /// <summary>
 /// Creates an instance of the child node class and adds it as a child of the parent node.
 /// </summary>
 /// <param name="node">
 /// The parent node to add the newly created <see cref="ChildNode"/>.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         childNode = CreateChild();
         node.AddNode(childNode);
         UIService.SetUIDirty(node.Hierarchy);
         UIService.ActivateNode(childNode);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
Example #5
0
        /// <summary>
        /// Adds either a <see cref="FieldNode"/>, <see cref="MethodNode"/> or <see cref="PropertyNode"/> to the current <see cref="RuleSetNode"/>,
        /// based on the selected member.
        /// </summary>
        /// <param name="node">The parent node to newly added configuration node.</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            try
            {
                UIService.BeginUpdate();
                Type type = FindType(node);
                if (type != null)
                {
                    IUIService        uiService     = ServiceHelper.GetUIService(serviceProvider);
                    TypeMemberChooser memberChooser = new TypeMemberChooser(uiService);
                    foreach (MemberInfo memberInfo in memberChooser.ChooseMembers(type))
                    {
                        if (memberInfo != null)
                        {
                            if (node.Nodes.Contains(memberInfo.Name))
                            {
                                continue;
                            }

                            ConfigurationNode childNode = null;
                            if (memberInfo is PropertyInfo)
                            {
                                childNode = new PropertyNode(memberInfo.Name);
                            }
                            else if (memberInfo is MethodInfo)
                            {
                                childNode = new MethodNode(memberInfo.Name);
                            }
                            else if (memberInfo is FieldInfo)
                            {
                                childNode = new FieldNode(memberInfo.Name);
                            }
                            else
                            {
                                Debug.Assert(false, "memberInfo should be either PropertyInfo, MethodInfo or FieldInfo");
                            }

                            node.AddNode(childNode);
                            UIService.SetUIDirty(node.Hierarchy);
                        }
                    }
                }
            }
            finally
            {
                UIService.EndUpdate();
            }
        }
Example #6
0
 /// <summary>
 /// Opens a previously saved configuration.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         OpenFile(node);
         if (ErrorLogService.ConfigurationErrorCount > 0)
         {
             UIService.DisplayErrorLog(ErrorLogService);
         }
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
Example #7
0
 /// <summary>
 /// <para>Creates an instance of the child node class and adds it as a child of the parent node.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The parent node to add the newly created <see cref="ChildNode"/>.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         childNode = CreateChild();
         node.Nodes.AddWithDefaultChildren(childNode);
         UIService.SetUIDirty(node.Hierarchy);
         UIService.ActivateNode(childNode);
         AddXmlIncludeTypes(node);
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
 /// <summary>
 /// Opens a previously saved configuration.
 /// </summary>
 /// <param name="node">
 /// The node to execute the command upon.
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         OpenFile();
         if (ErrorLogService.ConfigurationErrorCount > 0)
         {
             UIService.DisplayErrorLog(ErrorLogService);
             UIService.ShowMessage(Resources.OpenApplicationErrorMessage, Resources.OpenApplicationCaption);
         }
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
Example #9
0
 /// <summary>
 /// <para>Removes the node from the <see cref="IUIHierarchy"/>.</para>
 /// </summary>
 /// <param name="node">
 /// <para>The node to execute the command upon.</para>
 /// </param>
 protected override void ExecuteCore(ConfigurationNode node)
 {
     try
     {
         UIService.BeginUpdate();
         UIService.SetUIDirty(node.Hierarchy);
         node.Remove();
         using (RemoveXmlIncludeTypesCommand cmd = new RemoveXmlIncludeTypesCommand(ServiceProvider))
         {
             cmd.Execute(node);
         }
     }
     finally
     {
         UIService.EndUpdate();
     }
 }
Example #10
0
        /// <summary>
        /// Performs the merging of configuration, given a specific <see cref="EnvironmentNode"/>.
        /// </summary>
        /// <param name="node">The <see cref="EnvironmentNode"/> this command should be executed on.</param>
        protected override void ExecuteCore(ConfigurationNode node)
        {
            EnvironmentNode environmentNode = node as EnvironmentNode;

            if (environmentNode != null)
            {
                if (EnsureMainHierarchyIsSaved(node.Hierarchy, node.Site))
                {
                    EnvironmentMergeAware environmentMergeService = node.Site.GetService(typeof(EnvironmentMergeAware)) as EnvironmentMergeAware;

                    string originalFilePath      = Path.GetFullPath(node.Hierarchy.RootNode.ConfigurationFile);
                    string originalDirectoryPath = Path.GetDirectoryName(originalFilePath);
                    environmentMergeService.SetEnvironmentalMergeInProgress(true);

                    try
                    {
                        UIService.BeginUpdate();

                        Dictionary <string, ConfigurationNodeMergeData> mergeDataByPath = environmentNode.EnvironmentMergeData.UnfoldMergeData(environmentNode.Hierarchy, false);

                        string temporaryFilepath       = Path.GetTempFileName();
                        bool   temporarySaveSuccessful = false;
                        try
                        {
                            UpdateConfigurationSource(node.Hierarchy, temporaryFilepath);

                            SaveConfigurationApplicationNodeCommand saveConfigurationNodeCommand = new SaveConfigurationApplicationNodeCommand(ServiceProvider);
                            saveConfigurationNodeCommand.Execute(ServiceHelper.GetCurrentRootNode(ServiceProvider));
                            temporarySaveSuccessful = saveConfigurationNodeCommand.SaveSucceeded;
                        }
                        finally
                        {
                            UpdateConfigurationSource(node.Hierarchy, originalFilePath);
                            node.Hierarchy.ConfigurationSource    = null;
                            node.Hierarchy.ConfigurationParameter = null;
                        }

                        if (temporarySaveSuccessful)
                        {
                            using (TemporaryConfigurationHierarchy tempHierarchy = new TemporaryConfigurationHierarchy(ServiceProvider, temporaryFilepath))
                            {
                                MergeHierarchy(tempHierarchy.Hierarchy, mergeDataByPath);

                                SaveConfigurationApplicationNodeCommand saveConfigurationApplication = new SaveConfigurationApplicationNodeCommand(ServiceProvider);

                                string environmentConfigurationFile = CreateMergedConfigurationFile(environmentNode, originalFilePath, originalDirectoryPath);

                                UpdateConfigurationSource(tempHierarchy.Hierarchy, environmentConfigurationFile);
                                RemoveConfigurationSourceElements(tempHierarchy.Hierarchy);

                                saveConfigurationApplication.Execute(tempHierarchy.Hierarchy.RootNode);

                                mergeSucceeded          = saveConfigurationApplication.SaveSucceeded;
                                mergedConfigurationFile = environmentConfigurationFile;
                            }

                            try
                            {
                                File.Delete(temporaryFilepath);
                            }
                            catch (IOException)
                            {
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        IUIService uiService = ServiceHelper.GetUIService(ServiceProvider);
                        uiService.ShowError(e, Resources.ErrorSavingMergedConfigurationCaption);
                    }
                    finally
                    {
                        IConfigurationUIHierarchyService hierarchyService = ServiceHelper.GetUIHierarchyService(ServiceProvider);
                        hierarchyService.SelectedHierarchy = node.Hierarchy;

                        UIService.EndUpdate();

                        environmentMergeService.SetEnvironmentalMergeInProgress(false);
                    }
                }
            }
        }