Reference3.Collection 属性
获取一个 References 集合。
命名空间: VSLangProj80
程序集: VSLangProj80(在 VSLangProj80.dll 中)
语法
声明
ReadOnly Property Collection As References
References Collection { get; }
property References^ Collection {
References^ get ();
}
abstract Collection : References
function get Collection () : References
属性值
类型:VSLangProj.References
返回包含一个或多个 Reference3 对象的 References 集合。
示例
此示例显示打开的 Visual Basic 或 Visual C# 项目的引用集合。若要将此示例作为外接程序运行,请参见如何:编译和运行自动化对象模型代码示例。
Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
applicationObject = CType(application, DTE2)
addInInstance = CType(addInInst, AddIn)
DisplayCollections(applicationObject)
End Sub
Public Sub DisplayCollections(ByVal dte As DTE2)
' The first project is a Visual Basic or C# project.
Dim vsProject As VSProject2 = _
CType(applicationObject.Solution.Projects.Item(1)._
Object, VSProject2)
Dim aRef As Reference3
Dim refStr As String
refStr = ""
For Each aRef In vsProject.References
refStr += (aRef.Name & " " & aRef.Collection & vbCr)
Next
MsgBox(refStr)
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
applicationObject = (DTE2)application;
addInInstance = (AddIn)addInInst;
DisplayCollections(((DTE2)applicationObject));
}
public void DisplayCollections( DTE2 dte )
{
// The first project is a Visual Basic or C# project.
VSProject2 vsProject = ( ( VSProject2 )
( applicationObject.Solution.Projects.Item( 1 ).Object ) );
Reference aRef = null;
string refStr = null;
refStr = "";
foreach ( VSLangProj80.Reference3 temp in vsProject.References )
{
aRef = temp;
refStr += ( aRef.Name + " " + aRef.Collection + "\n" );
}
MessageBox.Show ( refStr);
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。