다음을 통해 공유


CodeAttribute2 인터페이스

코드 요소의 특성을 정의합니다.

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

구문

‘선언
<GuidAttribute("35187E2A-E5F6-4F89-A4CE-DA254640855B")> _
Public Interface CodeAttribute2 _
    Inherits CodeAttribute
[GuidAttribute("35187E2A-E5F6-4F89-A4CE-DA254640855B")]
public interface CodeAttribute2 : CodeAttribute
[GuidAttribute(L"35187E2A-E5F6-4F89-A4CE-DA254640855B")]
public interface class CodeAttribute2 : CodeAttribute
[<GuidAttribute("35187E2A-E5F6-4F89-A4CE-DA254640855B")>]
type CodeAttribute2 =  
    interface
        interface CodeAttribute
    end
public interface CodeAttribute2 extends CodeAttribute

CodeAttribute2 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 Arguments 이 특성과 관련된 CodeAttributeArgument 개체가 들어 있는 CodeElement 개체의 컬렉션을 가져옵니다.
Public 속성 Children (CodeAttribute에서 상속됨)
Public 속성 Children 이 코드 구문에 포함된 개체의 컬렉션을 가져옵니다.
Public 속성 Collection (CodeAttribute에서 상속됨)
Public 속성 Collection CodeAttribute2 개체의 컬렉션을 가져옵니다.
Public 속성 DTE (CodeAttribute에서 상속됨)
Public 속성 DTE 최상위 확장성 개체를 가져옵니다.
Public 속성 EndPoint (CodeAttribute에서 상속됨)
Public 속성 EndPoint 코드 특성의 끝 위치가 되는 편집 지점을 가져옵니다.
Public 속성 Extender[String] (CodeAttribute에서 상속됨)
Public 속성 Extender[String] 이 코드 특성에 사용 가능한 경우 요청한 Extender를 반환합니다.
Public 속성 ExtenderCATID (CodeAttribute에서 상속됨)
Public 속성 ExtenderCATID 개체의 Extender CATID(범주 ID)를 가져옵니다.
Public 속성 ExtenderNames (CodeAttribute에서 상속됨)
Public 속성 ExtenderNames 개체에 대해 사용할 수 있는 Extender의 이름 목록을 가져옵니다.
Public 속성 FullName (CodeAttribute에서 상속됨)
Public 속성 FullName 개체 파일의 전체 경로와 이름을 가져옵니다.
Public 속성 InfoLocation (CodeAttribute에서 상속됨)
Public 속성 InfoLocation 코드 모델을 가져옵니다.
Public 속성 IsCodeType (CodeAttribute에서 상속됨)
Public 속성 IsCodeType 이 개체로부터 CodeType 개체를 얻을 수 있는지 여부를 가져옵니다.
Public 속성 Kind (CodeAttribute에서 상속됨)
Public 속성 Kind 특성 형식을 나타내는 열거형을 가져옵니다.
Public 속성 Language (CodeAttribute에서 상속됨)
Public 속성 Language 특성을 작성하는 데 사용되는 프로그래밍 언어를 식별하는 상수를 가져옵니다.
Public 속성 Name (CodeAttribute에서 상속됨)
Public 속성 Name 코드 특성의 이름을 설정하거나 가져옵니다.
Public 속성 Parent (CodeAttribute에서 상속됨)
Public 속성 Parent 코드 특성의 바로 위 부모 개체를 가져옵니다.
Public 속성 ProjectItem (CodeAttribute에서 상속됨)
Public 속성 ProjectItem 코드 특성과 연결된 ProjectItem을 가져옵니다.
Public 속성 StartPoint (CodeAttribute에서 상속됨)
Public 속성 StartPoint 특성의 시작 부분을 정의하는 TextPoint을 가져옵니다.
Public 속성 Target 코드 특성의 대상을 설정하거나 가져옵니다.
Public 속성 Value (CodeAttribute에서 상속됨)
Public 속성 Value 코드 특성의 데이터를 설정하거나 가져옵니다.

위쪽

메서드

  이름 설명
Public 메서드 AddArgument 특성에 인수를 추가합니다.
Public 메서드 Delete() (CodeAttribute에서 상속됨)
Public 메서드 Delete() 코드 요소의 모든 특성을 제거합니다.
Public 메서드 GetEndPoint(vsCMPart) (CodeAttribute에서 상속됨)
Public 메서드 GetEndPoint(vsCMPart) 특성의 끝 위치를 표시하는 TextPoint 개체를 반환합니다.
Public 메서드 GetStartPoint(vsCMPart) (CodeAttribute에서 상속됨)
Public 메서드 GetStartPoint(vsCMPart) 특성의 시작 위치를 정의하는 TextPoint 개체를 반환합니다.

위쪽

설명

CodeAttribute2 개체는 코드 요소와 관련된 하나의 COM 메타데이터 특성을 나타냅니다.AddAttribute 메서드를 사용하여 새 특성을 추가할 수 있고 Delete 메서드를 사용하여 적절한 개체에서 특성을 삭제할 수 있습니다.이 개체를 사용하여 코드 특성 값을 가져오거나 설정할 수도 있습니다.

[!참고]

클래스, 구조체, 함수, 특성, 대리자 등의 코드 모델 요소를 특정한 방식으로 편집한 후에는 요소의 값이 명확하지 않을 수 있습니다. 즉, 요소의 값이 항상 같다고 할 수 없습니다.자세한 내용은 코드 모델을 사용하여 코드 검색(Visual Basic)의 "코드 모델 요소 값이 변경될 수 있음" 단원을 참조하십시오.

예제

// The following example creates a new namespace and attribute in the current class.
public void CreateClassAndAttrib(DTE2 applicationObject)
{
    // Before running, load or create a project.
    FileCodeModel2 fcm2 = GetFileCodeModel(applicationObject);
    CodeAttribute2 cmAttribute;
    CodeClass2 cmClass;

    if (fcm2 != null)
    {
        CodeNamespace cmNamespace;
        // Try to create a new namespace.
        try
        {
            cmNamespace = fcm2.AddNamespace("CMNamespace", -1);
            // If successful, create the other code elements.
            if (cmNamespace != null)
            {
                cmClass = (CodeClass2)cmNamespace.AddClass("ANewClass", 
                -1, null, null, vsCMAccess.vsCMAccessPrivate);
                cmAttribute = (CodeAttribute2)cmClass.AddAttribute
                ("NewAttribute", "AttributeValue", -1);
            }
            else
            {
                MessageBox.Show("Cannot continue - no filecodemodel 
                available.");
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("ERROR: " + ex);
        }
    }
}

public FileCodeModel2 GetFileCodeModel(DTE2 applicationObject)
{
    // Returns the FileCodeModel object of the active 
    // window.
    TextWindow txtWin = 
    (TextWindow)applicationObject.ActiveWindow.Object;
    FileCodeModel2 fcm2;
    if (txtWin != null)
    {
        try
        {
             fcm2 = (FileCodeModel2)txtWin.Parent.
             ProjectItem.FileCodeModel;
             return fcm2;
        }
        catch (Exception ex)
        {
             MessageBox.Show("ERROR: " + ex);
             return null;
        }
    }
    else
        return null;
}

참고 항목

참조

EnvDTE80 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행

코드 모델을 사용하여 코드 검색(Visual Basic)

코드 모델을 사용하여 코드 검색(Visual C#)