Solution4.Item 메서드
Projects 컬렉션의 인덱싱된 멤버를 반환합니다.
네임스페이스: EnvDTE100
어셈블리: EnvDTE100(EnvDTE100.dll)
구문
‘선언
Function Item ( _
index As Object _
) As Project
Project Item(
Object index
)
Project^ Item(
[InAttribute] Object^ index
)
abstract Item :
index:Object -> Project
function Item(
index : Object
) : Project
매개 변수
- index
형식: Object
반환 값
형식: Project
Project 개체입니다.
설명
Index에 전달된 값은 컬렉션의 개체에 대한 인덱스를 나타내는 정수입니다. Index의 값은 컬렉션의 개체에 해당하는 문자열 값일 수도 있습니다. 그러나 Item에 허용되는 정확한 값은 컬렉션과 해당 구현 방법에 따라 다릅니다.
Item 메서드는 컬렉션에서 인덱스 값에 해당하는 개체를 찾지 못하면 ArgumentException 예외를 throw합니다.
예제
이 추가 기능 코드를 실행하는 방법에 대한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.
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)
SolnItemExample(_applicationObject)
End Sub
Sub SolnItemExample(ByVal dte As DTE2)
' This add-in iterates through project items in a solution.
' Make sure you have a solution open in Visual
' Studio before running this example.
Try
Dim soln As Solution4 = _
CType(_applicationObject.Solution, Solution4)
' Dim solnName As String = _
System.IO.Path.GetFileNameWithoutExtension(soln.FullName)
Dim tempString As String = "The items in the solution are: " _
& vbCr
For i As Integer = 1 To soln.Projects.Count
tempString = tempString & soln.Item(i).Name.ToString() _
& vbCr
Next
MsgBox(tempString)
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
using System.Windows.Forms;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// Pass the applicationObject member variable to the code example.
SolnItemExample((DTE2)_applicationObject);
}
public void SolnItemExample(DTE2 dte)
{
// This add-in iterates through the project items in a solution.
// Open a solution in Visual Studio before running
// this example.
try
{
Solution4 soln = (Solution4)_applicationObject.Solution;
String tempString = "The items in the solution are: " + "\n";
for (int i = 1; i <= soln.Projects.Count; i++)
{
tempString = tempString + soln.Item(i).Name.ToString()
+ "\n";
}
MessageBox.Show(tempString);
}
catch (SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용를 참조하세요.