OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Collections.Generic; | |
5 using Microsoft.VisualStudio; | |
6 using Microsoft.VisualStudio.Shell.Interop; | |
7 | |
8 namespace Microsoft.VisualStudio.Project | |
9 { | |
10 [CLSCompliant(false)] | |
11 public class EnumDependencies : IVsEnumDependencies | |
12 { | |
13 private List<IVsDependency> dependencyList = new List<IVsDepende
ncy>(); | |
14 | |
15 private uint nextIndex; | |
16 | |
17 public EnumDependencies(IList<IVsDependency> dependencyList) | |
18 { | |
19 foreach(IVsDependency dependency in dependencyList) | |
20 { | |
21 this.dependencyList.Add(dependency); | |
22 } | |
23 } | |
24 | |
25 public EnumDependencies(IList<IVsBuildDependency> dependencyList
) | |
26 { | |
27 foreach(IVsBuildDependency dependency in dependencyList) | |
28 { | |
29 this.dependencyList.Add(dependency); | |
30 } | |
31 } | |
32 | |
33 public int Clone(out IVsEnumDependencies enumDependencies) | |
34 { | |
35 enumDependencies = new EnumDependencies(this.dependencyL
ist); | |
36 ErrorHandler.ThrowOnFailure(enumDependencies.Skip(this.n
extIndex)); | |
37 return VSConstants.S_OK; | |
38 } | |
39 | |
40 public int Next(uint elements, IVsDependency[] dependencies, out
uint elementsFetched) | |
41 { | |
42 uint fetched = 0; | |
43 int count = this.dependencyList.Count; | |
44 | |
45 while(this.nextIndex < count && elements > 0 && fetched
< count) | |
46 { | |
47 dependencies[fetched] = this.dependencyList[(int
)this.nextIndex]; | |
48 this.nextIndex++; | |
49 fetched++; | |
50 elements--; | |
51 | |
52 } | |
53 | |
54 elementsFetched = fetched; | |
55 | |
56 // Did we get 'em all? | |
57 return (elements == 0 ? VSConstants.S_OK : VSConstants.S
_FALSE); | |
58 } | |
59 | |
60 public int Reset() | |
61 { | |
62 this.nextIndex = 0; | |
63 return VSConstants.S_OK; | |
64 } | |
65 | |
66 public int Skip(uint elements) | |
67 { | |
68 this.nextIndex += elements; | |
69 uint count = (uint)this.dependencyList.Count; | |
70 | |
71 if(this.nextIndex > count) | |
72 { | |
73 this.nextIndex = count; | |
74 return VSConstants.S_FALSE; | |
75 } | |
76 return VSConstants.S_OK; | |
77 } | |
78 } | |
79 } | |
OLD | NEW |