/// <summary> /// Inherits properties from an existing property dictionary Instance. /// </summary> /// <param name="source">Property list to inherit.</param> /// <param name="excludes">The list of properties to exclude during inheritance.</param> public virtual void Inherit(PropertyDictionary source, StringCollection excludes) { foreach (DictionaryEntry entry in source.Dictionary) { string propertyName = (string)entry.Key; if (excludes != null && excludes.Contains(propertyName)) { continue; } // do not overwrite an existing read-only property if (IsReadOnlyProperty(propertyName)) { continue; } // add property to dictionary ValidatePropertyName(propertyName, Location.UnknownLocation); Dictionary[propertyName] = entry.Value; // if property is readonly, add to collection of readonly properties if (source.IsReadOnlyProperty(propertyName)) { _readOnlyProperties.Add(propertyName); } // if property is dynamic, add to collection of dynamic properties // if it was not already in that collection if (source.IsDynamicProperty(propertyName) && !IsDynamicProperty(propertyName)) { _dynamicProperties.Add(propertyName); } } }
public string GetPropertyValue(string propertyName) { if (_properties.IsDynamicProperty(propertyName)) { string currentState = (string)_state[propertyName]; // check for circular references if (currentState == PropertyDictionary.Visiting) { // Currently visiting this node, so have a cycle throw PropertyDictionary.CreateCircularException(propertyName, _visiting); } _visiting.Push(propertyName); _state[propertyName] = PropertyDictionary.Visiting; string propertyValue = _properties.GetPropertyValue(propertyName); if (propertyValue == null) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1053"), propertyName)); } Location propertyLocation = Location.UnknownLocation; // TODO - get the proper location of the property declaration propertyValue = _properties.ExpandProperties(propertyValue, propertyLocation, _state, _visiting); _visiting.Pop(); _state[propertyName] = PropertyDictionary.Visited; return(propertyValue); } else { string propertyValue = _properties.GetPropertyValue(propertyName); if (propertyValue == null) { throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1053"), propertyName)); } return(propertyValue); } }
/// <summary> /// Inherits properties from an existing property dictionary Instance. /// </summary> /// <param name="source">Property list to inherit.</param> /// <param name="excludes">The list of properties to exclude during inheritance.</param> public virtual void Inherit(PropertyDictionary source, StringCollection excludes) { foreach (DictionaryEntry entry in source.Dictionary) { string propertyName = (string) entry.Key; if (excludes != null && excludes.Contains(propertyName)) { continue; } // do not overwrite an existing read-only property if (IsReadOnlyProperty(propertyName)) { continue; } // add property to dictionary ValidatePropertyName(propertyName, Location.UnknownLocation); Dictionary[propertyName] = entry.Value; // if property is readonly, add to collection of readonly properties if (source.IsReadOnlyProperty(propertyName)) { _readOnlyProperties.Add(propertyName); } // if property is dynamic, add to collection of dynamic properties // if it was not already in that collection if (source.IsDynamicProperty(propertyName) && !IsDynamicProperty(propertyName)) { _dynamicProperties.Add(propertyName); } } }