this.originalProject = originalProject;
if (ProjectPath == String.Empty)
- throw new InvalidProjectFileException ("Project required attribute \"Project\" is missing from element <Import>.");
+ throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
}
internal void Evaluate ()
{
- string file;
- OldExpression exp;
+ evaluatedProjectPath = EvaluateProjectPath (ProjectPath);
+ string filename = GetFullPath ();
- exp = new OldExpression (project);
- exp.ParseSource (ProjectPath);
+ if (EvaluatedProjectPath == String.Empty)
+ throw new InvalidProjectFileException ("The required attribute \"Project\" is missing from element <Import>.");
- file = evaluatedProjectPath = (string) exp.ConvertTo (typeof (string));
-
- if (!Path.IsPathRooted (EvaluatedProjectPath) && project.FullFileName != String.Empty) {
- string dir;
- if (originalProject == null)
- dir = Path.GetDirectoryName (project.FullFileName);
- else
- dir = Path.GetDirectoryName (originalProject.FullFileName);
- file = Path.Combine (dir, EvaluatedProjectPath);
- }
-
- if (!File.Exists (file)) {
- throw new InvalidProjectFileException (String.Format ("Imported project: \"{0}\" does not exist.", file));
+ if (!File.Exists (filename)) {
+ throw new InvalidProjectFileException (String.Format ("Imported project: \"{0}\" does not exist.", filename));
}
ImportedProject importedProject = new ImportedProject ();
- importedProject.Load (file);
- // FIXME: UGLY HACK
+ importedProject.Load (filename);
+
project.ProcessElements (importedProject.XmlDocument.DocumentElement, importedProject);
}
+
+ string EvaluateProjectPath (string file)
+ {
+ Expression exp;
+
+ exp = new Expression ();
+ exp.Parse (file);
+ return (string) exp.ConvertTo (project, typeof (string));
+ }
+
+ string GetFullPath ()
+ {
+ string file = EvaluatedProjectPath;
+
+ if (!Path.IsPathRooted (EvaluatedProjectPath)) {
+ string dir = null;
+ if (originalProject == null) {
+ if (project.FullFileName != String.Empty) // Path.GetDirectoryName throws exception on String.Empty
+ dir = Path.GetDirectoryName (project.FullFileName);
+ } else {
+ if (originalProject.FullFileName != String.Empty)
+ dir = Path.GetDirectoryName (originalProject.FullFileName);
+ }
+ if (dir != null)
+ file = Path.Combine (dir, EvaluatedProjectPath);
+ }
+
+ return file;
+ }
public string Condition {
get {