[xbuild] Fix warnings.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / BuildChoose.cs
index b75954bc79ac3d61d354a2205f1c9bb1abff5131..53725110f80f87e692164f4cd3d46144747e6dda 100644 (file)
 #if NET_2_0
 
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.Xml;
 
 namespace Microsoft.Build.BuildEngine {
        internal class BuildChoose {
                
-               bool            isImported;
                BuildWhen       otherwise;
-               Project         project;
-               IList           whens;
+               //Project               project;
+               //ImportedProject       importedProject;
+               //XmlElement    xmlElement;
+               List <BuildWhen>        whens;
                
-               public BuildChoose (bool imported, Project project)
+               public BuildChoose (XmlElement xmlElement, Project project)
+                       : this (xmlElement, project, null)
                {
-                       this.isImported = imported;
-                       this.project = project; 
-                       this.whens = new ArrayList ();
                }
-               
-               public void BindToXml (XmlElement chooseElement)
+
+               internal BuildChoose (XmlElement xmlElement, Project project, ImportedProject importedProject)
                {
+                       //this.xmlElement = xmlElement;
+                       //this.project = project;
+                       //this.importedProject = importedProject;
+                       this.whens = new List <BuildWhen> ();
+
+                       foreach (XmlNode xn in xmlElement.ChildNodes) {
+                               if (!(xn is XmlElement))
+                                       continue;
+
+                               XmlElement xe = (XmlElement)xn;
+
+                               if (xe.Name == "When") {
+                                       if (otherwise != null)
+                                               throw new InvalidProjectFileException ("The 'Otherwise' element must be last in a 'Choose' element.");
+                                       if (xe.Attributes.GetNamedItem ("Condition") == null)
+                                               throw new InvalidProjectFileException ("The 'When' element requires a 'Condition' attribute.");
+                                       BuildWhen bw = new BuildWhen (xe, project);
+                                       whens.Add (bw);
+                               } else if (xe.Name == "Otherwise") {
+                                       if (this.whens.Count == 0)
+                                               throw new InvalidProjectFileException ("At least one 'When' element must occur in a 'Choose' element.");
+                                       
+                                       otherwise = new BuildWhen (xe, project);
+                               }
+                       }
+
+                       DefinedInFileName = importedProject != null ? importedProject.FullFileName :
+                                               project != null ? project.FullFileName : null;
                }
                
-               public bool IsImported {
-                       get { return isImported; }
-                       set { isImported = value; }
+               public void Evaluate ()
+               {
                }
                
+               //public bool IsImported {
+               //      get { return isImported; }
+               //      set { isImported = value; }
+               //}
+               
                public BuildWhen Otherwise {
                        get { return otherwise; }
                        set { otherwise = value; }
                }
                
-               public IList Whens {
+               public List <BuildWhen> Whens {
                        get { return whens; }
                        set { whens = value; }
                }
+
+               internal string DefinedInFileName { get; private set; }
        }
 }