ProjectItem.Name 속성
개체의 이름을 가져오거나 설정합니다.
네임스페이스: EnvDTE
어셈블리: EnvDTE(EnvDTE.dll)
구문
‘선언
Default Property Name As String
string this { get; set; }
property String^ default {
String^ get ();
void set (String^ value);
}
abstract Name : string with get, set
function get Name () : String
function set Name (value : String)
속성 값
형식: System.String
개체의 이름을 나타내는 문자열입니다.
예제
Sub NameExample(ByVal dte As DTE2)
' NOTE: This example requires a reference to the System.Text
' namespace.
' Before running this example, open a code document from a project.
Dim item As ProjectItem = dte.ActiveDocument.ProjectItem
Dim sb As New StringBuilder
RecurseElements(item.FileCodeModel.CodeElements, 0, sb)
MsgBox(item.Name & " contains the following elements:" & vbCrLf & _
vbCrLf & sb.ToString())
End Sub
Sub RecurseElements(ByVal elems As CodeElements, _
ByVal level As Integer, ByVal sb As StringBuilder)
Dim elem As CodeElement
For Each elem In elems
' Add element to the list of names.
sb.Append(" "c, level * 8)
sb.Append(elem.Name & " [" & elem.Kind.ToString() & "]" & _
vbCrLf)
' Call this function recursively if element has children.
If elem.Kind = vsCMElement.vsCMElementNamespace Then
RecurseElements(CType(elem, CodeNamespace).Members, _
level + 1, sb)
ElseIf elem.IsCodeType Then
RecurseElements(CType(elem, CodeType).Members, _
level + 1, sb)
End If
Next
End Sub
public void NameExample(DTE2 dte)
{
// NOTE: This example requires a reference to the
// System.Text namespace.
// Before running this example, open a code document from
// a project.
ProjectItem item = dte.ActiveDocument.ProjectItem;
StringBuilder sb = new StringBuilder();
RecurseElements(item.FileCodeModel.CodeElements, 0, sb);
MessageBox.Show(item.Name +
" contains the following elements:\n\n" + sb.ToString());
}
void RecurseElements(CodeElements elems, int level, StringBuilder sb)
{
foreach (CodeElement elem in elems)
{
// Add element to the list of names.
sb.Append(' ', level * 8);
sb.Append(elem.Name + " [" + elem.Kind.ToString() + "]\n");
// Call this function recursively if element has children.
if (elem.Kind == vsCMElement.vsCMElementNamespace)
RecurseElements(((CodeNamespace)elem).Members,
level + 1, sb);
else if (elem.IsCodeType)
RecurseElements(((CodeType)elem).Members, level + 1, sb);
}
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.