public bool ConfigurationMergePropertyMatchesProperty(EnvironmentOverriddenPropertyElement configurationMergeProperty, IEnvironmentalOverridesProperty runtimeProperty) { return(configurationMergeProperty != null && runtimeProperty != null && (string.Compare(configurationMergeProperty.ConfigurationSectionName, runtimeProperty.ConfigurationSectionName, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(configurationMergeProperty.ContainingElementXPath, runtimeProperty.ContainingElementXPath, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(configurationMergeProperty.Attribute, runtimeProperty.PropertyAttributeName, StringComparison.OrdinalIgnoreCase) == 0)); }
public void SetValue(Property originalProperty, object value) { var overridableProperty = GetOverridableProperty(originalProperty); var mergeElement = GetMergeElement(elementPath); var propertyAttributeName = overridableProperty.PropertyAttributeName; var convertedValue = (string)overridableProperty.DeltaConfigurationStorageConverter.ConvertFrom(originalProperty, CultureInfo.InvariantCulture, value); var containingElementXPath = overridableProperty.ContainingElementXPath; var containingSectionName = overridableProperty.ConfigurationSectionName; var containingSectionXpath = overridableProperty.ContainingSectionXPath; var existingEntry = mergeElement.OverriddenProperties. Cast <EnvironmentOverriddenPropertyElement>(). Where(x => ConfigurationMergePropertyMatchesProperty(x, overridableProperty)). FirstOrDefault(); if (existingEntry != null) { existingEntry.OverriddenValue = convertedValue; } else { var newEntry = new EnvironmentOverriddenPropertyElement { ConfigurationSectionName = containingSectionName, ContainingElementXPath = containingElementXPath, ContainingSectionXPath = containingSectionXpath, Attribute = propertyAttributeName, OverriddenValue = convertedValue }; mergeElement.OverriddenProperties.Add(newEntry); } }