/// <summary> /// Initializes with the argument that was provided with the command. /// </summary> /// <param name="argument">Argument that was provided with the command.</param> public void Initialize(string argument) { bool isDumpEnabled = false; if (!string.IsNullOrWhiteSpace(argument) && argument.Equals(Constants.BlameCollectDumpKey, StringComparison.OrdinalIgnoreCase)) { if (this.environment.OperatingSystem == PlatformOperatingSystem.Windows && this.environment.Architecture != PlatformArchitecture.ARM64 && this.environment.Architecture != PlatformArchitecture.ARM) { isDumpEnabled = true; } else { Output.Warning(false, CommandLineResources.BlameCollectDumpNotSupportedForPlatform); } } // Add Blame Logger EnableLoggerArgumentExecutor.AddLoggerToRunSettings(BlameFriendlyName, this.runSettingsManager); // Add Blame Data Collector CollectArgumentExecutor.AddDataCollectorToRunSettings(BlameFriendlyName, this.runSettingsManager); // Get results directory from RunSettingsManager var runSettings = this.runSettingsManager.ActiveRunSettings; string resultsDirectory = null; if (runSettings != null) { try { RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings.SettingsXml); resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); } catch (SettingsException se) { if (EqtTrace.IsErrorEnabled) { EqtTrace.Error("EnableBlameArgumentProcessor: Unable to get the test results directory: Error {0}", se); } } } // Add configuration element var settings = runSettings?.SettingsXml; if (settings == null) { runSettingsManager.AddDefaultRunSettings(); settings = runSettings?.SettingsXml; } var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings); if (dataCollectionRunSettings == null) { dataCollectionRunSettings = new DataCollectionRunSettings(); } var XmlDocument = new XmlDocument(); var outernode = XmlDocument.CreateElement("Configuration"); var node = XmlDocument.CreateElement("ResultsDirectory"); outernode.AppendChild(node); node.InnerText = resultsDirectory; if (isDumpEnabled) { var dumpNode = XmlDocument.CreateElement(Constants.BlameCollectDumpKey); outernode.AppendChild(dumpNode); } foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList) { if (item.FriendlyName.Equals(BlameFriendlyName)) { item.Configuration = outernode; } } runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); }
/// <summary> /// Initializes with the argument that was provided with the command. /// </summary> /// <param name="argument">Argument that was provided with the command.</param> public void Initialize(string argument) { // Add Blame Logger EnableLoggerArgumentExecutor.AddLoggerToRunSettings(BlameFriendlyName, this.runSettingsManager); // Add Blame Data Collector CollectArgumentExecutor.AddDataCollectorToRunSettings(BlameFriendlyName, this.runSettingsManager); // Get results directory from RunSettingsManager var runSettings = this.runSettingsManager.ActiveRunSettings; string resultsDirectory = null; if (runSettings != null) { try { RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings.SettingsXml); resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); } catch (SettingsException se) { if (EqtTrace.IsErrorEnabled) { EqtTrace.Error("EnableBlameArgumentProcessor: Unable to get the test results directory: Error {0}", se); } } } // Add configuration element var settings = runSettings?.SettingsXml; if (settings == null) { runSettingsManager.AddDefaultRunSettings(); settings = runSettings?.SettingsXml; } var dataCollectionRunSettings = XmlRunSettingsUtilities.GetDataCollectionRunSettings(settings); if (dataCollectionRunSettings == null) { dataCollectionRunSettings = new DataCollectionRunSettings(); } var XmlDocument = new XmlDocument(); var outernode = XmlDocument.CreateElement("Configuration"); var node = XmlDocument.CreateElement("ResultsDirectory"); outernode.AppendChild(node); node.InnerText = resultsDirectory; foreach (var item in dataCollectionRunSettings.DataCollectorSettingsList) { if (item.FriendlyName.Equals(BlameFriendlyName)) { item.Configuration = outernode; } } runSettingsManager.UpdateRunSettingsNodeInnerXml(Constants.DataCollectionRunSettingsName, dataCollectionRunSettings.ToXml().InnerXml); }