this.originalProject = originalProject;
if (ProjectPath == String.Empty)
- throw new InvalidProjectFileException ("Project attribute must be specified.");
+ 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 (!File.Exists (filename)) {
+ throw new InvalidProjectFileException (String.Format ("Imported project: \"{0}\" does not exist.", filename));
+ }
+
+ ImportedProject importedProject = new ImportedProject ();
+ importedProject.Load (filename);
- if (Path.IsPathRooted (EvaluatedProjectPath) == false) {
+ 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) && project.FullFileName != String.Empty) {
string dir;
if (originalProject == null)
dir = Path.GetDirectoryName (project.FullFileName);
dir = Path.GetDirectoryName (originalProject.FullFileName);
file = Path.Combine (dir, EvaluatedProjectPath);
}
-
- // FIXME: loggers anybody?
- if (!File.Exists (file)) {
- Console.WriteLine ("Imported file {0} doesn't exist.", file);
- return;
- }
- ImportedProject importedProject = new ImportedProject ();
- importedProject.Load (file);
- // FIXME: UGLY HACK
- project.ProcessElements (importedProject.XmlDocument.DocumentElement, importedProject);
+ return file;
}
public string Condition {
- get { return importElement.GetAttribute ("Condition"); }
+ get {
+ string s = importElement.GetAttribute ("Condition");
+ return s == String.Empty ? null : s;
+ }
}
public string EvaluatedProjectPath {