Merge pull request #1398 from jwestfall69/dgv-first_row_index
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Evaluation / ProjectItem.cs
index c94cb5b038943d1b2c689b68249a98eda27991b2..cc187f9b94c0b8e5f1f26d67bad8af188f55e205 100644 (file)
@@ -34,6 +34,8 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
 using Microsoft.Build.Construction;
+using System.IO;
+using Microsoft.Build.Framework;
 
 namespace Microsoft.Build.Evaluation
 {
@@ -47,15 +49,19 @@ 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)
                {
@@ -64,6 +70,11 @@ namespace Microsoft.Build.Evaluation
 
                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;
                }
@@ -88,6 +99,12 @@ namespace Microsoft.Build.Evaluation
 
                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 ();
                }
 
@@ -108,7 +125,7 @@ namespace Microsoft.Build.Evaluation
                }
 
                public bool IsImported {
-                       get { throw new NotImplementedException (); }
+                       get { return is_imported; }
                }
 
                public string ItemType {
@@ -135,6 +152,6 @@ namespace Microsoft.Build.Evaluation
 
                public ProjectItemElement Xml {
                        get { return xml; }
-               }
+               }               
        }
 }