Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Side by Side Diff: experimental/visual_studio_plugin/third_party/Microsoft.VisualStudio.Project/Automation/OANavigableProjectItems.cs

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /// Copyright (c) Microsoft Corporation. All rights reserved.
2
3 using System;
4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Diagnostics.CodeAnalysis;
7 using System.Runtime.InteropServices;
8
9 namespace Microsoft.VisualStudio.Project.Automation
10 {
11 /// <summary>
12 /// This can navigate a collection object only (partial implementation o f ProjectItems interface)
13 /// </summary>
14 [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrec tSuffix")]
15 [ComVisible(true), CLSCompliant(false)]
16 public class OANavigableProjectItems : EnvDTE.ProjectItems
17 {
18 #region fields
19 private OAProject project;
20 private IList<EnvDTE.ProjectItem> items;
21 private HierarchyNode nodeWithItems;
22 #endregion
23
24 #region properties
25 /// <summary>
26 /// Defines an internal list of project items
27 /// </summary>
28 internal IList<EnvDTE.ProjectItem> Items
29 {
30 get
31 {
32 return this.items;
33 }
34 }
35
36 /// <summary>
37 /// Defines a relationship to the associated project.
38 /// </summary>
39 internal OAProject Project
40 {
41 get
42 {
43 return this.project;
44 }
45 }
46
47 /// <summary>
48 /// Defines the node that contains the items
49 /// </summary>
50 internal HierarchyNode NodeWithItems
51 {
52 get
53 {
54 return this.nodeWithItems;
55 }
56 }
57 #endregion
58
59 #region ctor
60 /// <summary>
61 /// Constructor.
62 /// </summary>
63 /// <param name="project">The associated project.</param>
64 /// <param name="nodeWithItems">The node that defines the items. </param>
65 public OANavigableProjectItems(OAProject project, HierarchyNode nodeWithItems)
66 {
67 this.project = project;
68 this.nodeWithItems = nodeWithItems;
69 this.items = this.GetListOfProjectItems();
70 }
71
72 /// <summary>
73 /// Constructor.
74 /// </summary>
75 /// <param name="project">The associated project.</param>
76 /// <param name="items">A list of items that will make up the it ems defined by this object.</param>
77 /// <param name="nodeWithItems">The node that defines the items. </param>
78 public OANavigableProjectItems(OAProject project, IList<EnvDTE.P rojectItem> items, HierarchyNode nodeWithItems)
79 {
80 this.items = items;
81 this.project = project;
82 this.nodeWithItems = nodeWithItems;
83 }
84 #endregion
85
86 #region EnvDTE.ProjectItems
87
88 /// <summary>
89 /// Gets a value indicating the number of objects in the collect ion.
90 /// </summary>
91 public virtual int Count
92 {
93 get
94 {
95 return items.Count;
96 }
97 }
98
99 /// <summary>
100 /// Gets the immediate parent object of a ProjectItems collectio n.
101 /// </summary>
102 public virtual object Parent
103 {
104 get
105 {
106 return this.nodeWithItems.GetAutomationObject();
107 }
108 }
109
110 /// <summary>
111 /// Gets an enumeration indicating the type of object.
112 /// </summary>
113 public virtual string Kind
114 {
115 get
116 {
117 // TODO: Add OAProjectItems.Kind getter impleme ntation
118 return null;
119 }
120 }
121
122 /// <summary>
123 /// Gets the top-level extensibility object.
124 /// </summary>
125 public virtual EnvDTE.DTE DTE
126 {
127 get
128 {
129 return (EnvDTE.DTE)this.project.DTE;
130 }
131 }
132
133 /// <summary>
134 /// Gets the project hosting the project item or items.
135 /// </summary>
136 public virtual EnvDTE.Project ContainingProject
137 {
138 get
139 {
140 return this.project;
141 }
142 }
143
144 /// <summary>
145 /// Adds one or more ProjectItem objects from a directory to the ProjectItems collection.
146 /// </summary>
147 /// <param name="directory">The directory from which to add the project item.</param>
148 /// <returns>A ProjectItem object.</returns>
149 public virtual EnvDTE.ProjectItem AddFromDirectory(string direct ory)
150 {
151 throw new NotImplementedException();
152 }
153
154 /// <summary>
155 /// Creates a new project item from an existing item template fi le and adds it to the project.
156 /// </summary>
157 /// <param name="fileName">The full path and file name of the te mplate project file.</param>
158 /// <param name="name">The file name to use for the new project item.</param>
159 /// <returns>A ProjectItem object. </returns>
160 public virtual EnvDTE.ProjectItem AddFromTemplate(string fileNam e, string name)
161 {
162 throw new NotImplementedException();
163 }
164
165 /// <summary>
166 /// Creates a new folder in Solution Explorer.
167 /// </summary>
168 /// <param name="name">The name of the folder node in Solution E xplorer.</param>
169 /// <param name="kind">The type of folder to add. The available values are based on vsProjectItemsKindConstants and vsProjectItemKindConstants</ param>
170 /// <returns>A ProjectItem object.</returns>
171 public virtual EnvDTE.ProjectItem AddFolder(string name, string kind)
172 {
173 throw new NotImplementedException();
174 }
175
176 /// <summary>
177 /// Copies a source file and adds it to the project.
178 /// </summary>
179 /// <param name="filePath">The path and file name of the project item to be added.</param>
180 /// <returns>A ProjectItem object. </returns>
181 public virtual EnvDTE.ProjectItem AddFromFileCopy(string filePat h)
182 {
183 throw new NotImplementedException();
184 }
185
186 /// <summary>
187 /// Adds a project item from a file that is installed in a proje ct directory structure.
188 /// </summary>
189 /// <param name="fileName">The file name of the item to add as a project item. </param>
190 /// <returns>A ProjectItem object. </returns>
191 public virtual EnvDTE.ProjectItem AddFromFile(string fileName)
192 {
193 throw new NotImplementedException();
194 }
195
196 /// <summary>
197 /// Get Project Item from index
198 /// </summary>
199 /// <param name="index">Either index by number (1-based) or by n ame can be used to get the item</param>
200 /// <returns>Project Item. null is return if invalid index is sp ecified</returns>
201 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Perf ormance", "CA1800:DoNotCastUnnecessarily")]
202 public virtual EnvDTE.ProjectItem Item(object index)
203 {
204 if(index is int)
205 {
206 int realIndex = (int)index - 1;
207 if(realIndex >= 0 && realIndex < this.items.Coun t)
208 {
209 return (EnvDTE.ProjectItem)items[realInd ex];
210 }
211 return null;
212 }
213 else if(index is string)
214 {
215 string name = (string)index;
216 foreach(EnvDTE.ProjectItem item in items)
217 {
218 if(String.Compare(item.Name, name, Strin gComparison.OrdinalIgnoreCase) == 0)
219 {
220 return item;
221 }
222 }
223 }
224 return null;
225 }
226
227 /// <summary>
228 /// Returns an enumeration for items in a collection.
229 /// </summary>
230 /// <returns>An IEnumerator for this object.</returns>
231 public virtual IEnumerator GetEnumerator()
232 {
233 if(this.items == null)
234 {
235 yield return null;
236 }
237
238 int count = items.Count;
239 for(int i = 0; i < count; i++)
240 {
241 yield return items[i];
242 }
243 }
244
245 #endregion
246
247 #region virtual methods
248 /// <summary>
249 /// Retrives a list of items associated with the current node.
250 /// </summary>
251 /// <returns>A List of project items</returns>
252 protected IList<EnvDTE.ProjectItem> GetListOfProjectItems()
253 {
254 List<EnvDTE.ProjectItem> list = new List<EnvDTE.ProjectI tem>();
255 for(HierarchyNode child = this.NodeWithItems.FirstChild; child != null; child = child.NextSibling)
256 {
257 EnvDTE.ProjectItem item = child.GetAutomationObj ect() as EnvDTE.ProjectItem;
258 if(null != item)
259 {
260 list.Add(item);
261 }
262 }
263
264 return list;
265 }
266 #endregion
267 }
268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698