private void MergeGlobalAndEnvironmentKeyValues(WorkspaceConfig workspaceConfig) { if ( (workspaceConfig.KeyValues != null && workspaceConfig.KeyValues.Count > 0) && (workspaceConfig.Environments != null && workspaceConfig.Environments.Count > 0) ) { //for each environment foreach (KeyValuePair <EnvironmentsEnum, EnvironmentConfig> environment in workspaceConfig.Environments) { //if the environment has no KeyValues, then it inherits ALL global KeyValues if (environment.Value.KeyValues == null || environment.Value.KeyValues.Count == 0) { environment.Value.KeyValues = workspaceConfig.KeyValues; continue; } //if the environment has KeyValues, then it inherits all global KeyValues it doesn't override foreach (var kvp in workspaceConfig.KeyValues) { if (!environment.Value.KeyValues.ContainsKey(kvp.Key)) { environment.Value.KeyValues.Add(kvp.Key, kvp.Value); } } } } }
/// <summary> /// Entry point for KrutaConfigSectionHandler.Create() /// /// This method processes the WorkspaceConfig node of the HPE.Kruta.Common.Config, and returns an object that represents the configuration information. /// </summary> /// <param name="workspaceNode"></param> /// <returns>WorkspaceConfig</returns> internal WorkspaceConfig WorkspaceFactory(XmlNode workspaceNode) { var result = new WorkspaceConfig(); // Exit if there are no configuration settings. if (workspaceNode != null && workspaceNode.ChildNodes.Count > 0) { result.MachineConfig = MachineFactoryDefaultEnvironment(workspaceNode.SelectSingleNode(MachinesXml.MachinesNode)); result.Flags = FlagsFactory(workspaceNode.SelectSingleNode(FlagsXml.Node)); result.KeyValues = KeyValuesFactory(workspaceNode.SelectSingleNode(KeyValuesXml.Node)); // Attempt to match a machine node with the current machine, if there is no machine, a default has been provided by InitializeWorkspace() result.Environments = EnvironmentsFactory(workspaceNode.SelectSingleNode(EnvironmentsXml.EnvironmentsNode)); //must occur LAST MergeGlobalAndEnvironmentConfig(result); } return(result); }
private void MergeGlobalAndEnvironmentConfig(WorkspaceConfig workspaceConfig) { MergeGlobalAndEnvironmentFlags(workspaceConfig); MergeGlobalAndEnvironmentKeyValues(workspaceConfig); }