Merge pull request #819 from brendanzagaeski/patch-1
[mono.git] / mcs / class / Microsoft.Build / Microsoft.Build.Execution / ProjectTargetInstance.cs
1 //
2 // ProjectTargetInstance.cs
3 //
4 // Author:
5 //   Rolf Bjarne Kvinge (rolf@xamarin.com)
6 //   Atsushi Enomoto (atsshi@xamarin.com)
7 //
8 // Copyright (C) 2011,2013 Xamarin Inc.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30
31 using System;
32 using Microsoft.Build.Construction;
33 using System.Collections.Generic;
34 using System.Linq;
35
36 namespace Microsoft.Build.Execution
37 {
38 #if NET_4_5
39         public
40 #endif
41         sealed class ProjectTargetInstance
42         {
43                 internal ProjectTargetInstance (ProjectTargetElement xml)
44                 {
45                         FullPath = xml.ContainingProject.FullPath;
46                         Children = xml.Children.Select<ProjectElement,ProjectTargetInstanceChild> (c => {
47                                 if (c is ProjectOnErrorElement)
48                                         return new ProjectOnErrorInstance ((ProjectOnErrorElement) c);
49                                 if (c is ProjectItemGroupElement)
50                                         return new ProjectItemGroupTaskInstance ((ProjectItemGroupElement) c);
51                                 if (c is ProjectPropertyGroupElement)
52                                         return new ProjectPropertyGroupTaskInstance ((ProjectPropertyGroupElement) c);
53                                 if (c is ProjectTaskElement)
54                                         return new ProjectTaskInstance ((ProjectTaskElement) c);
55                                 throw new NotSupportedException ();
56                         }).ToArray ();
57                         Condition = xml.Condition;
58                         DependsOnTargets = xml.DependsOnTargets;
59                         //FullPath = fullPath;
60                         Inputs = xml.Inputs;
61                         KeepDuplicateOutputs = xml.KeepDuplicateOutputs;
62                         Name = xml.Name;
63                         OnErrorChildren = xml.OnErrors.Select (c => new ProjectOnErrorInstance (c)).ToArray ();
64                         Outputs = xml.Outputs;
65                         Returns = xml.Returns;
66                         Tasks = xml.Tasks.Select (t => new ProjectTaskInstance (t)).ToArray ();
67                         #if NET_4_5
68                         AfterTargetsLocation = xml.AfterTargetsLocation;
69                         BeforeTargetsLocation = xml.BeforeTargetsLocation;
70                         ConditionLocation = xml.ConditionLocation;
71                         DependsOnTargetsLocation = xml.DependsOnTargetsLocation;
72                         InputsLocation = xml.InputsLocation;
73                         KeepDuplicateOutputsLocation = xml.KeepDuplicateOutputsLocation;
74                         Location = xml.Location;
75                         OutputsLocation = xml.OutputsLocation;
76                         ReturnsLocation = xml.ReturnsLocation;
77                         #endif
78                 }
79
80                 public ElementLocation AfterTargetsLocation { get; private set; }
81                 public ElementLocation BeforeTargetsLocation { get; private set; }
82                 public IList<ProjectTargetInstanceChild> Children { get; private set; }
83                 public string Condition { get; private set; }
84                 public ElementLocation ConditionLocation { get; private set; }
85                 public string DependsOnTargets { get; private set; }
86                 public ElementLocation DependsOnTargetsLocation { get; private set; }
87                 public string FullPath { get; private set; }
88                 public string Inputs { get; private set; }
89                 public ElementLocation InputsLocation { get; private set; }
90                 public string KeepDuplicateOutputs { get; private set; }
91                 public ElementLocation KeepDuplicateOutputsLocation { get; private set; }
92                 public ElementLocation Location { get; private set; }
93                 public string Name { get; private set; }
94                 public IList<ProjectOnErrorInstance> OnErrorChildren { get; private set; }
95                 public string Outputs { get; private set; }
96                 public ElementLocation OutputsLocation { get; private set; }
97                 public string Returns { get; private set; }
98                 public ElementLocation ReturnsLocation { get; private set; }
99                 public ICollection<ProjectTaskInstance> Tasks { get; private set; }
100         }
101 }
102