コード例 #1
0
        void IPropertyGroupListener.PropertyRemoved(MSBuildProperty prop)
        {
            var ep = (MSBuildPropertyEvaluated)GetProperty(prop.Name);

            if (ep == null)
            {
                return;
            }

            if (ep.LinkedProperty != null)
            {
                // Unlink the property
                ep.LinkToProperty(null);

                // The corresponding evaluated property instance will be removed id
                // 1) It didn't exist when the project was loaded
                // 2) The property did exist in the property group when the project was loaded,
                //    which means that the evaluated property is actually the result of evaluating
                //    that property group property.
                if (ep.IsNew || !prop.IsNew)
                {
                    ep.IsNew = false;
                    properties.Remove(ep.Name);
                }
            }
        }
コード例 #2
0
        public void LinkToProperty(MSBuildProperty property)
        {
            // Binds this evaluated property to a property defined in a property group, so that if this evaluated property
            // is modified, the change will be propagated to that linked property.
            linkedProperty = property;

            if (EvaluatedValueIsStale && property != null)
            {
                // This will be true if the property has been modified in the project,
                // which means that the evaluated value of the property may be out of date.
                // In that case, we set the EvaluatedValueModified on the linked property,
                // which means that the property will be saved no matter what the
                // evaluated value was. Also, InitEvaluatedValue() is not called
                // because the evaluated value we have is stale

                property.EvaluatedValueModified = true;
                return;
            }

            // Initialize the linked property with the evaluated property only if it has not yet modified (it doesn't have
            // its own value).
            if (linkedProperty != null && !linkedProperty.Modified && !IsNew)
            {
                linkedProperty.InitEvaluatedValue(evaluatedValue, DefinedMultipleTimes || property.IsNew);
            }

            // DefinedMultipleTimes is used to determine if the property value has been set several times during evaluation.
            // This is useful to know because if the property is set only once, we know that if we remove the property definition,
            // we are resetting the property to an empty value, and not just inheriting a value from a previous definition.
            // This information is provided to the linked property in the InitEvaluatedValue call, and used later on
            // when saving the project to determine if the property definition can be removed or not.
            // If property.IsNew==true it means that the property was not defined in the property group, and it is now
            // being defined. It means that the property will actually end having multiple definitions (the definition
            // that generated this evaluated property, and the new one in the property group).
        }
コード例 #3
0
 public void LinkToProperty(MSBuildProperty property)
 {
     linkedProperty = property;
     if (linkedProperty != null && !linkedProperty.Modified && !IsNew)
     {
         linkedProperty.InitEvaluatedValue(evaluatedValue);
     }
 }
コード例 #4
0
 public void RemoveProperty(MSBuildProperty prop)
 {
     AssertCanModify();
     prop.RemoveIndent();
     properties.Remove(prop.Name);
     ChildNodes = ChildNodes.Remove(prop);
     NotifyChanged();
 }
コード例 #5
0
 void Evaluate(ProjectInfo project, MSBuildEvaluationContext context, MSBuildProperty prop)
 {
     if (string.IsNullOrEmpty(prop.Condition) || SafeParseAndEvaluate(project, context, prop.Condition, true))
     {
         var val = context.EvaluateString(prop.Value);
         project.Properties [prop.Name] = new PropertyInfo {
             Name = prop.Name, Value = prop.Value, FinalValue = val
         };
         context.SetPropertyValue(prop.Name, val);
     }
 }
コード例 #6
0
        MSBuildProperty AddProperty(string name, string condition = null)
        {
            AssertCanModify();
            int i           = propertyOrder.IndexOf(name);
            int insertIndex = -1;

            if (i != -1)
            {
                var foundProp = FindExistingProperty(i - 1, -1);
                if (foundProp != null)
                {
                    insertIndex = ChildNodes.IndexOf(foundProp) + 1;
                }
                else
                {
                    foundProp = FindExistingProperty(i + 1, 1);
                    if (foundProp != null)
                    {
                        insertIndex = ChildNodes.IndexOf(foundProp);
                    }
                }
            }

            var prop = new MSBuildProperty(name);

            prop.IsNew        = true;
            prop.ParentNode   = PropertiesParent;
            prop.Owner        = this;
            properties [name] = prop;

            if (insertIndex != -1)
            {
                ChildNodes = ChildNodes.Insert(insertIndex, prop);
            }
            else
            {
                ChildNodes = ChildNodes.Add(prop);
            }

            if (condition != null)
            {
                prop.Condition = condition;
            }

            prop.ResetIndent(false);

            if (PropertyGroupListener != null)
            {
                PropertyGroupListener.PropertyAdded(prop);
            }

            NotifyChanged();
            return(prop);
        }
コード例 #7
0
        public bool RemoveProperty(string name)
        {
            MSBuildProperty prop = GetProperty(name);

            if (prop != null)
            {
                RemoveProperty(prop);
                return(true);
            }
            return(false);
        }
コード例 #8
0
 public void RemoveProperty(MSBuildProperty prop)
 {
     AssertCanModify();
     if (PropertyGroupListener != null)
     {
         PropertyGroupListener.PropertyRemoved(prop);
     }
     prop.RemoveIndent();
     properties.Remove(prop.Name);
     ChildNodes = ChildNodes.Remove(prop);
     NotifyChanged();
 }
コード例 #9
0
        void IPropertyGroupListener.PropertyAdded(MSBuildProperty prop)
        {
            var p = (MSBuildPropertyEvaluated)GetProperty(prop.Name);

            if (p == null || p.LinkedProperty == null)
            {
                if (p == null)
                {
                    p = AddProperty(prop.Name);
                }
                p.LinkToProperty(prop);
            }
        }
コード例 #10
0
        public void SetPropertyValue(string name, string value, bool preserveExistingCase)
        {
            MSBuildProperty p = GetProperty(name);

            if (p != null)
            {
                if (!preserveExistingCase || !string.Equals(value, p.Value, StringComparison.OrdinalIgnoreCase))
                {
                    p.SetValue(value);
                }
                return;
            }
            groups [0].SetValue(name, value, preserveExistingCase: preserveExistingCase);
        }
コード例 #11
0
 public IMSBuildPropertySet GetGroupForProperty(string name)
 {
     // Find property in reverse order, since the last set
     // value is the good one
     for (int n = groups.Count - 1; n >= 1; n--)
     {
         var             g = groups [n];
         MSBuildProperty p = g.GetProperty(name);
         if (p != null)
         {
             return(g);
         }
     }
     return(groups[0]);
 }
コード例 #12
0
        internal override void ReadChildElement(MSBuildXmlReader reader)
        {
            MSBuildProperty prevSameName;

            if (properties.TryGetValue(reader.LocalName, out prevSameName))
            {
                prevSameName.Overwritten = true;
            }

            var prop = new MSBuildProperty();

            prop.ParentNode = PropertiesParent;
            prop.Owner      = this;
            prop.Read(reader);
            ChildNodes             = ChildNodes.Add(prop);
            properties [prop.Name] = prop;             // If a property is defined more than once, we only care about the last registered value
        }
コード例 #13
0
        internal override void ReadUnknownAttribute(MSBuildXmlReader reader, string lastAttr)
        {
            MSBuildProperty prevSameName;

            if (properties.TryGetValue(reader.LocalName, out prevSameName))
            {
                prevSameName.Overwritten = true;
            }

            var prop = new MSBuildProperty();

            prop.ParentNode = PropertiesParent;
            prop.Owner      = this;
            prop.ReadUnknownAttribute(reader, lastAttr);
            ChildNodes = ChildNodes.Add(prop);
            properties = properties.SetItem(prop.Name, prop);             // If a property is defined more than once, we only care about the last registered value
            PropertiesAttributeOrder.Add(prop);
        }
コード例 #14
0
        void IPropertyGroupListener.PropertyRemoved(MSBuildProperty prop)
        {
            var ep = (MSBuildPropertyEvaluated)GetProperty(prop.Name);

            if (ep == null)
            {
                return;
            }

            if (ep.LinkedProperty != null)
            {
                // Unlink the property
                ep.LinkToProperty(null);
                if (ep.IsNew)
                {
                    ep.IsNew = false;
                    properties.Remove(ep.Name);
                }
            }
        }
コード例 #15
0
        void IPropertyGroupListener.PropertyAdded(MSBuildProperty prop)
        {
            var p = (MSBuildPropertyEvaluated)GetProperty(prop.Name);

            if (p == null || p.LinkedProperty == null)
            {
                if (p == null)
                {
                    p = AddProperty(prop.Name);
                }
                p.LinkToProperty(prop);

                // This will be true if the property has been modified in the project,
                // which means that the evaluated value of the property may be out of date.
                // In that case, we set the EvaluatedValueModified on the linked property,
                // which means that the property will be saved no matter what the
                // evaluated value was.
                if (p.EvaluatedValueModified)
                {
                    prop.EvaluatedValueModified = true;
                }
            }
        }
コード例 #16
0
		void Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildProperty prop)
		{
			if (string.IsNullOrEmpty (prop.Condition) || SafeParseAndEvaluate (project, context, prop.Condition, true)) {
				bool needsItemEvaluation;
				var val = context.Evaluate (prop.UnevaluatedValue, out needsItemEvaluation);
				if (needsItemEvaluation)
					context.SetPropertyNeedsTransformEvaluation (prop.Name);
				project.Properties [prop.Name] = new PropertyInfo { Name = prop.Name, Value = prop.UnevaluatedValue, FinalValue = val };
				context.SetPropertyValue (prop.Name, val);
			}
		}
コード例 #17
0
		void Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildProperty prop)
		{
			if (string.IsNullOrEmpty (prop.Condition) || SafeParseAndEvaluate (project, context, prop.Condition, true)) {
				var val = context.EvaluateString (prop.Value);
				project.Properties [prop.Name] = new PropertyInfo { Name = prop.Name, Value = prop.Value, FinalValue = val };
				context.SetPropertyValue (prop.Name, val);
			}
		}
コード例 #18
0
		public void LinkToProperty (MSBuildProperty property)
		{
			linkedProperty = property;
			if (linkedProperty != null && !linkedProperty.Modified && !IsNew)
				linkedProperty.InitEvaluatedValue (evaluatedValue);
		}