public BuildWhen (XmlElement whenElement, Project parentProject)
		{
			this.parentProject = parentProject;
			this.groupingCollection = new GroupingCollection (parentProject);
			if (whenElement == null)
				throw new ArgumentNullException ("whenElement");
			this.whenElement = whenElement;
			foreach (XmlElement xe in whenElement.ChildNodes) {
				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));
				}
			}
		}
Exemple #2
0
        public BuildWhen(XmlElement whenElement, Project parentProject)
        {
            //this.parentProject = parentProject;
            this.groupingCollection = new GroupingCollection(parentProject);
            if (whenElement == null)
            {
                throw new ArgumentNullException("whenElement");
            }
            this.whenElement = whenElement;
            foreach (XmlElement xe in whenElement.ChildNodes)
            {
                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));
                }
            }
        }
Exemple #3
0
 internal void Add(BuildChoose bc)
 {
     chooses++;
     if (add_iterator == null)
     {
         list.AddLast(bc);
     }
     else
     {
         list.AddAfter(add_iterator, bc);
         add_iterator = add_iterator.Next;
     }
 }
 void EvaluateBuildChoose(BuildChoose bc)
 {
     project.PushThisFileProperty(bc.DefinedInFileName);
     try {
         bool whenUsed = false;
         foreach (BuildWhen bw in bc.Whens)
         {
             if (ConditionParser.ParseAndEvaluate(bw.Condition, project))
             {
                 bw.Evaluate();
                 whenUsed = true;
                 break;
             }
         }
         if (!whenUsed && bc.Otherwise != null &&
             ConditionParser.ParseAndEvaluate(bc.Otherwise.Condition, project))
         {
             bc.Otherwise.Evaluate();
         }
     } finally {
         project.PopThisFileProperty();
     }
 }
Exemple #5
0
        internal void Evaluate(EvaluationType type)
        {
            BuildItemGroup          big;
            BuildPropertyGroup      bpg;
            Import                  import;
            LinkedListNode <object> evaluate_iterator;

            if (type == EvaluationType.Property)
            {
                evaluate_iterator = list.First;
                add_iterator      = list.First;

                while (evaluate_iterator != null)
                {
                    if (evaluate_iterator.Value is BuildPropertyGroup)
                    {
                        bpg = (BuildPropertyGroup)evaluate_iterator.Value;
                        if (ConditionParser.ParseAndEvaluate(bpg.Condition, project))
                        {
                            bpg.Evaluate();
                        }
                    }

                    // if it wasn't moved by adding anything because of evaluating a Import shift it
                    if (add_iterator == evaluate_iterator)
                    {
                        add_iterator = add_iterator.Next;
                    }

                    evaluate_iterator = evaluate_iterator.Next;
                }
            }
            else if (type == EvaluationType.Item)
            {
                evaluate_iterator = list.First;
                add_iterator      = list.First;

                while (evaluate_iterator != null)
                {
                    if (evaluate_iterator.Value is BuildItemGroup)
                    {
                        big = (BuildItemGroup)evaluate_iterator.Value;
                        if (ConditionParser.ParseAndEvaluate(big.Condition, project))
                        {
                            big.Evaluate();
                        }
                    }

                    evaluate_iterator = evaluate_iterator.Next;
                }
            }
            else if (type == EvaluationType.Choose)
            {
                evaluate_iterator = list.First;
                add_iterator      = list.First;

                while (evaluate_iterator != null)
                {
                    if (evaluate_iterator.Value is BuildChoose)
                    {
                        BuildChoose bc       = (BuildChoose)evaluate_iterator.Value;
                        bool        whenUsed = false;
                        foreach (BuildWhen bw in bc.Whens)
                        {
                            if (ConditionParser.ParseAndEvaluate(bw.Condition, project))
                            {
                                bw.Evaluate();
                                whenUsed = true;
                                break;
                            }
                        }
                        if (!whenUsed && bc.Otherwise != null &&
                            ConditionParser.ParseAndEvaluate(bc.Otherwise.Condition, project))
                        {
                            bc.Otherwise.Evaluate();
                        }
                    }

                    evaluate_iterator = evaluate_iterator.Next;
                }
            }

            add_iterator = null;
        }
		internal void Add (BuildChoose bc)
		{
			chooses++;
			if (add_iterator == null)
				list.AddLast (bc);
			else {
				list.AddAfter (add_iterator, bc);
				add_iterator = add_iterator.Next;
			}
		}
Exemple #7
0
		void EvaluateBuildChoose (BuildChoose bc)
		{
			project.PushThisFileProperty (bc.DefinedInFileName);
			try {
				bool whenUsed = false;
				foreach (BuildWhen bw in bc.Whens) {
					if (ConditionParser.ParseAndEvaluate (bw.Condition, project)) {
						bw.Evaluate ();
						whenUsed = true;
						break;
					}
				}
				if (!whenUsed && bc.Otherwise != null &&
					ConditionParser.ParseAndEvaluate (bc.Otherwise.Condition, project)) {
					bc.Otherwise.Evaluate ();
				}
			} finally {
				project.PopThisFileProperty ();
			}
		}