OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Diagnostics; | |
5 using Microsoft.VisualStudio; | |
6 using Microsoft.VisualStudio.Shell; | |
7 using Microsoft.VisualStudio.Shell.Interop; | |
8 | |
9 namespace Microsoft.VisualStudio.Project | |
10 { | |
11 class Output : IVsOutput2 | |
12 { | |
13 private ProjectNode project; | |
14 private ProjectElement output; | |
15 | |
16 /// <summary> | |
17 /// Constructor for IVSOutput2 implementation | |
18 /// </summary> | |
19 /// <param name="projectManager">Project that produce this outpu
t</param> | |
20 /// <param name="outputAssembly">MSBuild generated item correspo
nding to the output assembly (by default, these would be of type MainAssembly</p
aram> | |
21 public Output(ProjectNode projectManager, ProjectElement outputA
ssembly) | |
22 { | |
23 if(projectManager == null) | |
24 throw new ArgumentNullException("projectManager"
); | |
25 if(outputAssembly == null) | |
26 throw new ArgumentNullException("outputAssembly"
); | |
27 | |
28 project = projectManager; | |
29 output = outputAssembly; | |
30 } | |
31 | |
32 #region IVsOutput2 Members | |
33 | |
34 public int get_CanonicalName(out string pbstrCanonicalName) | |
35 { | |
36 // Get the output assembly path (including the name) | |
37 pbstrCanonicalName = output.GetMetadata(ProjectFileConst
ants.Include); | |
38 Debug.Assert(!String.IsNullOrEmpty(pbstrCanonicalName),
"Output Assembly not defined"); | |
39 | |
40 // Make sure we have a full path | |
41 if(!System.IO.Path.IsPathRooted(pbstrCanonicalName)) | |
42 { | |
43 pbstrCanonicalName = new Url(project.BaseURI, pb
strCanonicalName).AbsoluteUrl; | |
44 } | |
45 return VSConstants.S_OK; | |
46 } | |
47 | |
48 /// <summary> | |
49 /// This path must start with file:/// if it wants other project | |
50 /// to be able to reference the output on disk. | |
51 /// If the output is not on disk, then this requirement does not | |
52 /// apply as other projects probably don't know how to access it
. | |
53 /// </summary> | |
54 public virtual int get_DeploySourceURL(out string pbstrDeploySou
rceURL) | |
55 { | |
56 string path = output.GetEvaluatedMetadata(ProjectFileCon
stants.FinalOutputPath); | |
57 if(string.IsNullOrEmpty(path)) | |
58 { | |
59 throw new InvalidOperationException(); | |
60 } | |
61 if(path.Length < 9 || String.Compare(path.Substring(0, 8
), "file:///", StringComparison.OrdinalIgnoreCase) != 0) | |
62 path = "file:///" + path; | |
63 pbstrDeploySourceURL = path; | |
64 return VSConstants.S_OK; | |
65 } | |
66 | |
67 public int get_DisplayName(out string pbstrDisplayName) | |
68 { | |
69 return this.get_CanonicalName(out pbstrDisplayName); | |
70 } | |
71 | |
72 public virtual int get_Property(string szProperty, out object pv
ar) | |
73 { | |
74 pvar = null; | |
75 String value = output.GetMetadata(szProperty); | |
76 // If we don't have a value, we are expected to return u
nimplemented | |
77 if(String.IsNullOrEmpty(value)) | |
78 throw new NotImplementedException(); | |
79 pvar = value; | |
80 return VSConstants.S_OK; | |
81 | |
82 } | |
83 | |
84 public int get_RootRelativeURL(out string pbstrRelativePath) | |
85 { | |
86 pbstrRelativePath = String.Empty; | |
87 object variant; | |
88 // get the corresponding property | |
89 | |
90 if(ErrorHandler.Succeeded(this.get_Property("TargetPath"
, out variant))) | |
91 { | |
92 string var = variant as String; | |
93 | |
94 if(var != null) | |
95 { | |
96 pbstrRelativePath = var; | |
97 } | |
98 } | |
99 | |
100 return VSConstants.S_OK; | |
101 } | |
102 | |
103 public virtual int get_Type(out Guid pguidType) | |
104 { | |
105 pguidType = Guid.Empty; | |
106 throw new NotImplementedException(); | |
107 } | |
108 | |
109 #endregion | |
110 } | |
111 } | |
OLD | NEW |