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
1 つ以上の 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 セキュリティ
- 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。