共用方式為


Reference3.Collection 屬性

取得 References 的集合。

命名空間:  VSLangProj80
組件:  VSLangProj80 (在 VSLangProj80.dll 中)

語法

'宣告
ReadOnly Property Collection As References
    Get
References Collection { get; }
property References^ Collection {
    References^ get ();
}
abstract Collection : References
function get Collection () : References

屬性值

型別:VSLangProj.References
傳回 References 集合,其中含有一或多個 Reference3 物件。

實作

Reference2.Collection

範例

此範例會針對開啟的 Visual Basic 或 Visual C# 專案顯示參考集合。 若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

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 安全性

請參閱

參考

Reference3 介面

Collection 多載

VSLangProj80 命名空間