using System.Diagnostics;
using System.Linq;
using Microsoft.Build.Construction;
+using System.IO;
+using Microsoft.Build.Framework;
namespace Microsoft.Build.Evaluation
{
if (project.ItemDefinitions.ContainsKey (ItemType))
foreach (var md in project.ItemDefinitions [ItemType].Metadata)
metadata.Add (md);
- foreach (var item in xml.Metadata)
- metadata.Add (new ProjectMetadata (project, ItemType, metadata, m => metadata.Remove (m), item));
- evaluated_include = evaluatedInclude;
+ foreach (var md in xml.Metadata)
+ metadata.Add (new ProjectMetadata (project, ItemType, metadata, m => metadata.Remove (m), md));
+ this.evaluated_include = evaluatedInclude;
+ is_imported = project.ProjectCollection.OngoingImports.Any ();
}
- Project project;
- ProjectItemElement xml;
- List<ProjectMetadata> metadata = new List<ProjectMetadata> ();
- string evaluated_include;
+ readonly Project project;
+ readonly ProjectItemElement xml;
+ readonly List<ProjectMetadata> metadata = new List<ProjectMetadata> ();
+ readonly bool is_imported;
+ readonly string evaluated_include;
+
+ internal string RecursiveDir { get; set; }
public ProjectMetadata GetMetadata (string name)
{
public string GetMetadataValue (string name)
{
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ var wk = ProjectCollection.GetWellKnownMetadata (name, EvaluatedInclude, project.GetFullPath, RecursiveDir);
+ if (wk != null)
+ return wk;
var m = GetMetadata (name);
return m != null ? m.EvaluatedValue : string.Empty;
}
public ProjectMetadata SetMetadataValue (string name, string unevaluatedValue)
{
+ // This has to do several tasks:
+ // - it cannot directly change Xml.Metadata because the ProjectItemElement might be shared
+ // among multiple ProjectItems.
+ // - hence it has to create another ProjectItemElement instance and add it to the project
+ // XML construction, with specific Include value that is assigned to this instance, and
+ // metadata values that are assigned to this instance.
throw new NotImplementedException ();
}
}
public bool IsImported {
- get { throw new NotImplementedException (); }
+ get { return is_imported; }
}
public string ItemType {
public ProjectItemElement Xml {
get { return xml; }
- }
+ }
}
}