#if NET_2_0
+using System;
using System.Collections;
using System.Collections.Generic;
}
}
+ internal void Remove (BuildItemGroup big)
+ {
+ if (big.ParentProject != project)
+ throw new InvalidOperationException (
+ "The \"BuildItemGroup\" object specified does not belong to the correct \"Project\" object.");
+
+ big.Detach ();
+ list.Remove (big);
+ }
+
+ internal void Remove (BuildPropertyGroup bpg)
+ {
+ // FIXME: add bpg.Detach ();
+ bpg.XmlElement.ParentNode.RemoveChild (bpg.XmlElement);
+ list.Remove (bpg);
+ }
+
internal void Evaluate ()
{
Evaluate (EvaluationType.Property);
-
Evaluate (EvaluationType.Item);
+ Evaluate (EvaluationType.Choose);
}
- void Evaluate (EvaluationType type)
+ internal void Evaluate (EvaluationType type)
{
BuildItemGroup big;
BuildPropertyGroup bpg;
- Import import;
LinkedListNode <object> evaluate_iterator;
if (type == EvaluationType.Property) {
while (evaluate_iterator != null) {
if (evaluate_iterator.Value is BuildPropertyGroup) {
bpg = (BuildPropertyGroup) evaluate_iterator.Value;
- if (ConditionParser.ParseAndEvaluate (bpg.Condition, project))
- bpg.Evaluate ();
- } else if (evaluate_iterator.Value is Import) {
- import = (Import) evaluate_iterator.Value;
- if (ConditionParser.ParseAndEvaluate (import.Condition, project))
- import.Evaluate ();
+ project.PushThisFileProperty (bpg.DefinedInFileName);
+ try {
+ if (ConditionParser.ParseAndEvaluate (bpg.Condition, project))
+ bpg.Evaluate ();
+ } finally {
+ project.PopThisFileProperty ();
+ }
}
// if it wasn't moved by adding anything because of evaluating a Import shift it
evaluate_iterator = evaluate_iterator.Next;
}
- } else {
+ } 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 ();
+ project.PushThisFileProperty (big.DefinedInFileName);
+ try {
+ if (ConditionParser.ParseAndEvaluate (big.Condition, project))
+ big.Evaluate ();
+ } finally {
+ project.PopThisFileProperty ();
+ }
+ }
+
+ 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;
+ 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 ();
+ }
}
evaluate_iterator = evaluate_iterator.Next;
}
}
+
+ add_iterator = null;
}
internal int Imports {
enum EvaluationType {
Property,
- Item
+ Item,
+ Choose
}
}