/// <summary>
        /// Adds node under RunConfiguration setting. No op if node is already present.
        /// </summary>
        private static void AddNodeIfNotPresent <T>(XmlDocument xmlDocument, string nodePath, string nodeName, T nodeValue, bool overwrite = false)
        {
            // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration
            var root = xmlDocument.DocumentElement;

            if (root.SelectSingleNode(RunConfigurationNodePath) == null)
            {
                EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + xmlDocument.LocalName);
                return;
            }

            var node = xmlDocument.SelectSingleNode(nodePath);

            if (node == null || overwrite)
            {
                XmlUtilities.AppendOrModifyChild(xmlDocument, nodePath, nodeName, nodeValue.ToString());
            }
        }
Example #2
0
        /// <summary>
        /// Updates the <c>RunConfiguration.DesignMode</c> value for a run settings. Doesn't do anything if the value is already set.
        /// </summary>
        /// <param name="runSettingsNavigator">Navigator for runsettings xml</param>
        /// <param name="designModeValue">Value to set</param>
        public static void UpdateDesignMode(XPathNavigator runSettingsNavigator, bool designModeValue)
        {
            // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration
            if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) ||
                !runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty))
            {
                EqtTrace.Error("InferRunSettingsHelper.UpdateDesignMode: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName);
                return;
            }

            var hasDesignMode = runSettingsNavigator.SelectSingleNode(DesignModeNodePath) != null;

            if (!hasDesignMode)
            {
                XmlUtilities.AppendOrModifyChild(runSettingsNavigator, DesignModeNodePath, DesignModeNodeName, designModeValue.ToString());
                runSettingsNavigator.MoveToRoot();
            }
        }
        /// <summary>
        /// Adds node under RunConfiguration setting. Noop if node is already present.
        /// </summary>
        private static void AddNodeIfNotPresent <T>(XPathNavigator runSettingsNavigator, string nodePath, string nodeName, T nodeValue, bool overwrite = false)
        {
            // Navigator should be at Root of runsettings xml, attempt to move to /RunSettings/RunConfiguration
            if (!runSettingsNavigator.MoveToChild(RunSettingsNodeName, string.Empty) ||
                !runSettingsNavigator.MoveToChild(RunConfigurationNodeName, string.Empty))
            {
                EqtTrace.Error("InferRunSettingsHelper.UpdateNodeIfNotPresent: Unable to navigate to RunConfiguration. Current node: " + runSettingsNavigator.LocalName);
                return;
            }

            var node = runSettingsNavigator.SelectSingleNode(nodePath);

            if (node == null || overwrite)
            {
                XmlUtilities.AppendOrModifyChild(runSettingsNavigator, nodePath, nodeName, nodeValue.ToString());
                runSettingsNavigator.MoveToRoot();
            }
        }
        /// <summary>
        /// Regenerates the RunConfiguration node with new values under runsettings.
        /// </summary>
        private static void UpdateRunConfiguration(
            XmlDocument xmlDocument,
            Architecture effectivePlatform,
            Framework effectiveFramework,
            string resultsDirectory)
        {
            var childNode = xmlDocument.SelectSingleNode(ResultsDirectoryNodePath);

            if (null != childNode)
            {
                resultsDirectory = childNode.InnerXml;
            }

            XmlUtilities.AppendOrModifyChild(xmlDocument, RunConfigurationNodePath, RunConfigurationNodeName, null);
            XmlUtilities.AppendOrModifyChild(xmlDocument, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory);

            XmlUtilities.AppendOrModifyChild(xmlDocument, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString());
            XmlUtilities.AppendOrModifyChild(xmlDocument, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString());
        }
Example #5
0
        /// <summary>
        /// Regenerates the RunConfiguration node with new values under runsettings.
        /// </summary>
        private static void UpdateRunConfiguration(
            XPathNavigator navigator,
            Architecture effectivePlatform,
            Framework effectiveFramework,
            string resultsDirectory)
        {
            var resultsDirectoryNavigator = navigator.SelectSingleNode(ResultsDirectoryNodePath);

            if (null != resultsDirectoryNavigator)
            {
                resultsDirectory = resultsDirectoryNavigator.InnerXml;
            }

            XmlUtilities.AppendOrModifyChild(navigator, RunConfigurationNodePath, RunConfigurationNodeName, null);
            navigator.MoveToChild(RunConfigurationNodeName, string.Empty);

            XmlUtilities.AppendOrModifyChild(navigator, ResultsDirectoryNodePath, ResultsDirectoryNodeName, resultsDirectory);

            XmlUtilities.AppendOrModifyChild(navigator, TargetPlatformNodePath, TargetPlatformNodeName, effectivePlatform.ToString());
            XmlUtilities.AppendOrModifyChild(navigator, TargetFrameworkNodePath, TargetFrameworkNodeName, effectiveFramework.ToString());

            navigator.MoveToRoot();
        }