/// <summary> /// Returns an unique identifier which can be used to identify this <see cref="EnvironmentOverriddenPropertyElement"/> instance within its collection. /// </summary> /// <param name="element">The <see cref="EnvironmentOverriddenPropertyElement"/> to return an identier for.</param> /// <returns>An <see cref="Object"/> that acts as the key for the specified <see cref="EnvironmentOverriddenPropertyElement"/>.</returns> protected override object GetElementKey(ConfigurationElement element) { EnvironmentOverriddenPropertyElement environmentNodeMerge = element as EnvironmentOverriddenPropertyElement; if (environmentNodeMerge != null) { return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", environmentNodeMerge.ContainingElementXPath, environmentNodeMerge.Attribute)); } throw new InvalidOperationException(); }
/// <summary> /// Removed an instance of <see cref="EnvironmentOverriddenPropertyElement"/> from the collection. /// </summary> /// <param name="property">An instance of <see cref="EnvironmentOverriddenPropertyElement"/>.</param> public void Remove(EnvironmentOverriddenPropertyElement property) { base.BaseRemove(GetElementKey(property)); }
/// <summary> /// Adds an instance of <see cref="EnvironmentOverriddenPropertyElement"/> to the collection. /// </summary> /// <param name="property">An instance of <see cref="EnvironmentOverriddenPropertyElement"/>.</param> public void Add(EnvironmentOverriddenPropertyElement property) { base.BaseAdd(property); }
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); } }
/// <summary> /// Removed an instance of <see cref="EnvironmentOverriddenPropertyElement"/> from the collection. /// </summary> /// <param name="property">An instance of <see cref="EnvironmentOverriddenPropertyElement"/>.</param> public void Remove(EnvironmentOverriddenPropertyElement property) { base.BaseRemove(GetElementKey(property)); }
/// <summary> /// Adds an instance of <see cref="EnvironmentOverriddenPropertyElement"/> to the collection. /// </summary> /// <param name="property">An instance of <see cref="EnvironmentOverriddenPropertyElement"/>.</param> public void Add(EnvironmentOverriddenPropertyElement property) { base.BaseAdd(property); }