Exemplo n.º 1
0
        static void RemovePropertyIfHasDefaultValue(
            MSBuildPropertyGroup propertyGroup,
            string propertyName,
            string defaultPropertyValue)
        {
            if (!propertyGroup.HasProperty(propertyName))
            {
                return;
            }

            if (propertyGroup.GetValue(propertyName) == defaultPropertyValue)
            {
                propertyGroup.RemoveProperty(propertyName);
            }
        }
        internal void CopyFrom(MSBuildPropertyGroup other)
        {
            AssertCanModify();
            foreach (var node in other.ChildNodes)
            {
                var prop = node as MSBuildProperty;
                if (prop != null)
                {
                    var cp = prop.Clone();
                    var currentPropIndex = ChildNodes.FindIndex(p => (p is MSBuildProperty) && ((MSBuildProperty)p).Name == prop.Name);
                    if (currentPropIndex != -1)
                    {
                        var currentProp = (MSBuildProperty)ChildNodes [currentPropIndex];
                        ChildNodes = ChildNodes.SetItem(currentPropIndex, cp);
                    }
                    else
                    {
                        ChildNodes = ChildNodes.Add(cp);
                    }
                    properties [cp.Name] = cp;
                    cp.ParentNode        = PropertiesParent;
                    cp.Owner             = this;
                    cp.ResetIndent(false);
                }
                else
                {
                    ChildNodes = ChildNodes.Add(node);
                }
            }
            foreach (var prop in ChildNodes.OfType <MSBuildProperty> ().ToArray())
            {
                if (!other.HasProperty(prop.Name))
                {
                    RemoveProperty(prop);
                }
            }

            NotifyChanged();
        }