ContextAttributes.Add 메서드

특성 이름/값 쌍을 ContextAttributes 컬렉션에 추가합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Function Add ( _
    AttributeName As String, _
    AttributeValue As String, _
    Type As vsContextAttributeType _
) As ContextAttribute
ContextAttribute Add(
    string AttributeName,
    string AttributeValue,
    vsContextAttributeType Type
)
ContextAttribute^ Add(
    String^ AttributeName, 
    String^ AttributeValue, 
    vsContextAttributeType Type
)
abstract Add : 
        AttributeName:string * 
        AttributeValue:string * 
        Type:vsContextAttributeType -> ContextAttribute 
function Add(
    AttributeName : String, 
    AttributeValue : String, 
    Type : vsContextAttributeType
) : ContextAttribute

매개 변수

  • AttributeName
    형식: System.String
    필수적 요소로서,새 특성의 이름입니다.
  • AttributeValue
    형식: System.String
    필수적 요소로서,새 특성의 값입니다.

반환 값

형식: EnvDTE.ContextAttribute
ContextAttribute 개체입니다.

설명

Add를 사용하면 컬렉션(컨텍스트 모음)에 새 특성을 추가하거나 키워드를 만들 수 있습니다.

참고

메서드를 호출하는 컬렉션 개체의 TypevsContextAttributesGlobal로 설정된 경우 이 메서드는 E_NOTIMPL과 함께 실패합니다.

예제

Sub AddExample()
   ' Get a reference to Solution Explorer.
   Dim SolnEx As Window = DTE.Windows.Item _
   (Constants.vsWindowKindSolutionExplorer)
   Dim CA As ContextAttribute

   ' List the current attributes associated with Solution Explorer.
   ListAttr(SolnEx, CA)

   ' Associate a new F1 keyword with Solution Explorer.
   SolnEx.ContextAttributes.Add("ANewKeyword", 900, _
   vsContextAttributeType.vsContextAttributeLookupF1)
   ListAttr(SolnEx, CA)

   ' Delete the new F1 keyword from Solution Explorer.
   SolnEx.ContextAttributes.Item(3).Remove()
   ListAttr(SolnEx, CA)
End Sub

Sub ListAttr(ByVal SolnEx As Object, ByVal CA As ContextAttribute)
   ' Support function for CATest(). Lists the current attributes 
   ' associated with Solution Explorer.
   Dim msg As String

   MsgBox("Number of context attributes in Solution Explorer: " & _
   SolnEx.ContextAttributes.Count)
   For Each CA In SolnEx.ContextAttributes
      msg = msg & CA.Name & Chr(13)
   Next
   MsgBox(msg)
   msg = ""
End Sub

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

ContextAttributes 인터페이스

EnvDTE 네임스페이스