示例#1
0
文件: Project.cs 项目: nikson/msbuild
        /// <summary>
        /// Removes a &lt;PropertyGroup&gt; from the main project file.
        /// </summary>
        /// <param name="propertyGroupToRemove"></param>
        /// <owner>RGoel</owner>
        public void RemovePropertyGroup
        (
            BuildPropertyGroup propertyGroupToRemove
        )
        {
            error.VerifyThrowArgumentNull(propertyGroupToRemove, "propertyGroupToRemove");

            // Confirm that it's not an imported property group.
            error.VerifyThrowInvalidOperation(!propertyGroupToRemove.IsImported,
                "CannotModifyImportedProjects");

            // Confirm that it's actually a persisted BuildPropertyGroup in the current project.
            error.VerifyThrowInvalidOperation(
                (propertyGroupToRemove.ParentProject == this) && (propertyGroupToRemove.PropertyGroupElement != null),
                "IncorrectObjectAssociation", "BuildPropertyGroup", "Project");

            // Clear out the children of the property group.
            propertyGroupToRemove.Clear();

            XmlElement parentElement = propertyGroupToRemove.ParentElement;
            ErrorUtilities.VerifyThrow(parentElement != null, "Why doesn't this PG have a parent XML element?");
            parentElement.RemoveChild(propertyGroupToRemove.PropertyGroupElement);

            ErrorUtilities.VerifyThrow(propertyGroupToRemove.ParentCollection != null, "Why doesn't this PG have a parent collection?");
            propertyGroupToRemove.ParentCollection.RemovePropertyGroup(propertyGroupToRemove);

            propertyGroupToRemove.ClearParentProject();

            this.MarkProjectAsDirty();
        }
示例#2
0
		public void TestClear1 ()
		{
			bpg = new BuildPropertyGroup ();
			
			bpg.SetProperty ("a", "b");
			Assert.AreEqual (1, bpg.Count, "A1");
			bpg.Clear ();
			Assert.AreEqual (0, bpg.Count, "A2");
		}
        public void CountAfterClear()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();
            group.SetProperty("n", "v");
            group.Clear();

            Assertion.AssertEquals(0, group.Count);
        }