Now our MS.Build.dll behaves like MS.Build.Engine.dll, replace \ with / at expansion...
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Evaluation / ProjectMetadata.cs
index 45001f61a243323be0da41f561ba924338d06282..880a0e336be40952f44dc8a024845f712a99c18e 100644 (file)
@@ -2,8 +2,9 @@
 //
 // Author:
 //   Rolf Bjarne Kvinge (rolf@xamarin.com)
+//   Atsushi Enomoto (atsushi@xamarin.com)
 //
-// Copyright (C) 2011 Xamarin Inc.
+// Copyright (C) 2011,2013 Xamarin Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 //
 
 using Microsoft.Build.Construction;
-
 using System;
+using System.Collections.Generic;
+using System.Linq;
 
 namespace Microsoft.Build.Evaluation
 {
-        public class ProjectMetadata
-        {
-                private ProjectMetadata ()
-                {
-                        throw new NotImplementedException ();
-                }
+       public class ProjectMetadata
+       {
+               internal ProjectMetadata (Project project, string itemType, IEnumerable<ProjectMetadata> existingMetadata, Action<ProjectMetadata> remover, ProjectMetadataElement xml)
+               {
+                       this.xml = xml;
+                       this.project = project;
+                       item_type = itemType;
+                       predecessor = existingMetadata.FirstOrDefault (m => m.Name == xml.Name);
+                       if (predecessor != null)
+                               remover (predecessor);
+                       is_imported = Project.ProjectCollection.OngoingImports.Any ();
+               }
+
+               readonly Project project;
+               readonly string item_type;
+               readonly ProjectMetadataElement xml;
+               readonly ProjectMetadata predecessor;
+               readonly bool is_imported;
 
-                public string EvaluatedValue {
-                        get { throw new NotImplementedException (); }
-                }
+               public string EvaluatedValue {
+                       get { return project.ExpandString (xml.Value); }
+               }
 
-                public bool IsImported {
-                        get { throw new NotImplementedException (); }
-                }
+               public bool IsImported {
+                       get { return is_imported; }
+               }
 
-                public string ItemType {
-                        get { throw new NotImplementedException (); }
-                }
+               public string ItemType {
+                       get { return item_type; }
+               }
 
-                public string Name {
-                        get { throw new NotImplementedException (); }
-                }
+               public string Name {
+                       get { return xml.Name; }
+               }
 
-                public ProjectMetadata Predecessor {
-                        get { throw new NotImplementedException (); }
-                }
+               public ProjectMetadata Predecessor {
+                       get { return predecessor; }
+               }
 
-                public Project Project {
-                        get { throw new NotImplementedException (); }
-                }
+               public Project Project {
+                       get { return project; }
+               }
 
-                public string UnevaluatedValue {
-                        get { throw new NotImplementedException (); }
-                }
+               public string UnevaluatedValue {
+                       get { return xml.Value; }
+               }
 
-                public ProjectMetadataElement Xml {
-                        get { throw new NotImplementedException (); }
-                }
-        }
+               public ProjectMetadataElement Xml {
+                       get { return xml; }
+               }
+       }
 }