OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Reflection; | |
5 using System.Runtime.InteropServices; | |
6 | |
7 namespace Microsoft.VisualStudio.Project.Automation | |
8 { | |
9 [CLSCompliant(false), ComVisible(true)] | |
10 public class OAProperty : EnvDTE.Property | |
11 { | |
12 #region fields | |
13 private OAProperties parent; | |
14 private PropertyInfo pi; | |
15 #endregion | |
16 | |
17 #region ctors | |
18 | |
19 public OAProperty(OAProperties parent, PropertyInfo pi) | |
20 { | |
21 this.parent = parent; | |
22 this.pi = pi; | |
23 } | |
24 #endregion | |
25 | |
26 #region EnvDTE.Property | |
27 /// <summary> | |
28 /// Microsoft Internal Use Only. | |
29 /// </summary> | |
30 public object Application | |
31 { | |
32 get { return null; } | |
33 } | |
34 | |
35 /// <summary> | |
36 /// Gets the Collection containing the Property object supportin
g this property. | |
37 /// </summary> | |
38 public EnvDTE.Properties Collection | |
39 { | |
40 get | |
41 { | |
42 //todo: EnvDTE.Property.Collection | |
43 return this.parent; | |
44 } | |
45 } | |
46 | |
47 /// <summary> | |
48 /// Gets the top-level extensibility object. | |
49 /// </summary> | |
50 public EnvDTE.DTE DTE | |
51 { | |
52 get | |
53 { | |
54 return this.parent.DTE; | |
55 } | |
56 } | |
57 | |
58 /// <summary> | |
59 /// Returns one element of a list. | |
60 /// </summary> | |
61 /// <param name="index1">The index of the item to display.</para
m> | |
62 /// <param name="index2">The index of the item to display. Reser
ved for future use.</param> | |
63 /// <param name="index3">The index of the item to display. Reser
ved for future use.</param> | |
64 /// <param name="index4">The index of the item to display. Reser
ved for future use.</param> | |
65 /// <returns>The value of a property</returns> | |
66 public object get_IndexedValue(object index1, object index2, obj
ect index3, object index4) | |
67 { | |
68 ParameterInfo[] par = pi.GetIndexParameters(); | |
69 int len = Math.Min(par.Length, 4); | |
70 if(len == 0) return this.Value; | |
71 object[] index = new object[len]; | |
72 Array.Copy(new object[4] { index1, index2, index3, index
4 }, index, len); | |
73 return this.pi.GetValue(this.parent.Target, index); | |
74 } | |
75 | |
76 /// <summary> | |
77 /// Setter function to set properties values. | |
78 /// </summary> | |
79 /// <param name="value"></param> | |
80 public void let_Value(object value) | |
81 { | |
82 this.Value = value; | |
83 } | |
84 | |
85 /// <summary> | |
86 /// Gets the name of the object. | |
87 /// </summary> | |
88 public string Name | |
89 { | |
90 get | |
91 { | |
92 return pi.Name; | |
93 } | |
94 } | |
95 | |
96 /// <summary> | |
97 /// Gets the number of indices required to access the value. | |
98 /// </summary> | |
99 public short NumIndices | |
100 { | |
101 get { return (short)pi.GetIndexParameters().Length; } | |
102 } | |
103 | |
104 /// <summary> | |
105 /// Sets or gets the object supporting the Property object. | |
106 /// </summary> | |
107 public object Object | |
108 { | |
109 get | |
110 { | |
111 return this.parent.Target; | |
112 } | |
113 set | |
114 { | |
115 } | |
116 } | |
117 | |
118 /// <summary> | |
119 /// Microsoft Internal Use Only. | |
120 /// </summary> | |
121 public EnvDTE.Properties Parent | |
122 { | |
123 get { return this.parent; } | |
124 } | |
125 | |
126 /// <summary> | |
127 /// Sets the value of the property at the specified index. | |
128 /// </summary> | |
129 /// <param name="index1">The index of the item to set.</param> | |
130 /// <param name="index2">Reserved for future use.</param> | |
131 /// <param name="index3">Reserved for future use.</param> | |
132 /// <param name="index4">Reserved for future use.</param> | |
133 /// <param name="value">The value to set.</param> | |
134 public void set_IndexedValue(object index1, object index2, objec
t index3, object index4, object value) | |
135 { | |
136 ParameterInfo[] par = pi.GetIndexParameters(); | |
137 int len = Math.Min(par.Length, 4); | |
138 if(len == 0) | |
139 { | |
140 this.Value = value; | |
141 } | |
142 else | |
143 { | |
144 object[] index = new object[len]; | |
145 Array.Copy(new object[4] { index1, index2, index
3, index4 }, index, len); | |
146 | |
147 using(AutomationScope scope = new AutomationScop
e(this.parent.Target.Node.ProjectMgr.Site)) | |
148 { | |
149 this.pi.SetValue(this.parent.Target, val
ue, index); | |
150 } | |
151 } | |
152 | |
153 } | |
154 | |
155 /// <summary> | |
156 /// Gets or sets the value of the property returned by the Prope
rty object. | |
157 /// </summary> | |
158 public object Value | |
159 { | |
160 get { return pi.GetValue(this.parent.Target, null); } | |
161 set | |
162 { | |
163 using(AutomationScope scope = new AutomationScop
e(this.parent.Target.Node.ProjectMgr.Site)) | |
164 { | |
165 this.pi.SetValue(this.parent.Target, val
ue, null); | |
166 } | |
167 } | |
168 } | |
169 #endregion | |
170 } | |
171 } | |
OLD | NEW |