[xbuild] Fix warnings.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / BuildWhen.cs
index 60dfaa238f1825570c4c4b24159583c629de9887..f243f679f22b9503c0da57ddcc9471434aa4b155 100644 (file)
@@ -33,42 +33,47 @@ using System.Xml;
 
 namespace Microsoft.Build.BuildEngine {
        internal class BuildWhen {
-               XmlAttribute            condition;
                //Project                       parentProject;
                GroupingCollection      groupingCollection;
                XmlElement              whenElement;
        
-               public BuildWhen (Project parentProject)
-               {
-               //      this.parentProject = parentProject;
-                       this.groupingCollection = new GroupingCollection ();
-               }
-               
-               public void BindToXml (XmlElement whenElement)
+               public BuildWhen (XmlElement whenElement, Project parentProject)
                {
+                       //this.parentProject = parentProject;
+                       this.groupingCollection = new GroupingCollection (parentProject);
                        if (whenElement == null)
                                throw new ArgumentNullException ("whenElement");
                        this.whenElement = whenElement;
-                       if (whenElement.GetAttribute ("Condition") != String.Empty)
-                               condition = whenElement.GetAttributeNode ("Condition");
                        foreach (XmlElement xe in whenElement.ChildNodes) {
-                               if (xe.Name == "ItemGroup") {
-                                       BuildItemGroup big = new BuildItemGroup ();
-                                       //big.BindToXml (xe);
-                                       groupingCollection.Add (big);
-                               // FIXME: add nested chooses
-                               } else if (xe.Name == "PropertyGroup") {
-                                       BuildPropertyGroup bpg = new BuildPropertyGroup ();
-                                       //bpg.BindToXml (xe);
-                                       groupingCollection.Add (bpg);
-                               } else
-                                       throw new InvalidProjectFileException ("Invalid element in When.");
+                               switch (xe.Name) {
+                                       case "ItemGroup":
+                                               BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
+                                               //big.BindToXml (xe);
+                                               groupingCollection.Add (big);
+                                               break;
+                                       case "PropertyGroup":
+                                               BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
+                                               //bpg.BindToXml (xe);
+                                               groupingCollection.Add (bpg);
+                                               break;
+                                       case "Choose":
+                                               BuildChoose bc = new BuildChoose (xe, parentProject);
+                                               groupingCollection.Add (bc);
+                                               break;
+                                       default:
+                                               throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
+                               }
                        }
                }
+
+               public void Evaluate()
+               {
+                       groupingCollection.Evaluate ();
+               }
                
                public string Condition {
-                       get { return condition.Value; }
-                       set { condition.Value = value; }
+                       get { return whenElement.GetAttribute ("Condition"); }
+                       set { whenElement.SetAttribute ("Condition", value); }
                }
                
                public GroupingCollection GroupingCollection {
@@ -78,4 +83,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif