DesignOnlyAttribute 클래스

정의

디자인 타임에서만 속성을 설정할 수 있는지 여부를 지정합니다.

public ref class DesignOnlyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class DesignOnlyAttribute : Attribute
public sealed class DesignOnlyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type DesignOnlyAttribute = class
    inherit Attribute
type DesignOnlyAttribute = class
    inherit Attribute
Public NotInheritable Class DesignOnlyAttribute
Inherits Attribute
상속
DesignOnlyAttribute
특성

예제

다음 예제에서는 속성을 만듭니다 GetLanguage . 속성은 로 DesignOnlyAttribute표시됩니다.

public:
   [DesignOnly(true)]
   property CultureInfo^ GetLanguage 
   {
      CultureInfo^ get()
      {
         // Insert code here.
         return myCultureInfo;
      }
      void set( CultureInfo^ value )
      {
         // Insert code here.
      }
   }
[DesignOnly(true)]
 public CultureInfo GetLanguage {
    get {
       // Insert code here.
       return myCultureInfo;
    }
    set {
       // Insert code here.
    }
 }
<DesignOnly(True)> _
Public Property GetLanguage() As CultureInfo
    Get
        ' Insert code here.
        Return myCultureInfo
    End Get
    Set
        ' Insert code here.
    End Set
End Property

다음 예제에서는 의 DesignOnlyAttribute값을 가져옵니다. 먼저 코드를 가져옵니다는 PropertyDescriptorCollection 개체에 대 한 모든 속성을 사용 하 여 합니다. 그런 다음 에 인덱싱 PropertyDescriptorCollection 하여 속성을 찾습니다 GetLanguage . 그런 다음이 속성에 대 한 특성을 반환 하 고 특성 변수에 저장 합니다.

그런 다음, 속성이 에서 AttributeCollection검색하여 DesignOnlyAttribute 콘솔 화면에 쓰는 경우에만 디자인인지 여부를 출력합니다.

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "GetLanguage" ]->Attributes;

/* Prints whether the property is marked as DesignOnly 
by retrieving the DesignOnlyAttribute from the AttributeCollection. */
DesignOnlyAttribute^ myAttribute = dynamic_cast<DesignOnlyAttribute^>(attributes[ DesignOnlyAttribute::typeid ]);
Console::WriteLine( "This property is design only :{0}", myAttribute->IsDesignOnly );
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["GetLanguage"].Attributes;

 /* Prints whether the property is marked as DesignOnly 
  * by retrieving the DesignOnlyAttribute from the AttributeCollection. */
 DesignOnlyAttribute myAttribute = 
    (DesignOnlyAttribute)attributes[typeof(DesignOnlyAttribute)];
 Console.WriteLine("This property is design only :" +
    myAttribute.IsDesignOnly.ToString());
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("GetLanguage").Attributes

' Prints whether the property is marked as DesignOnly 
' by retrieving the DesignOnlyAttribute from the AttributeCollection.
Dim myAttribute As DesignOnlyAttribute = _
    CType(attributes(GetType(DesignOnlyAttribute)), DesignOnlyAttribute)
Console.WriteLine(("This property is design only :" & _
    myAttribute.IsDesignOnly.ToString()))

설명

로 설정된 true 멤버는 DesignOnlyAttribute 디자인 타임에만 설정할 수 있습니다. 일반적으로 이러한 속성은 디자인 타임에만 존재하며 런타임에 개체의 실제 속성에 해당하지 않습니다.

특성이 없거나 로 설정된 false 멤버는 DesignOnlyAttribute 런타임에 설정할 수 있습니다. 기본값은 false입니다.

가 로 설정된 true 속성 DesignOnlyAttribute 의 값은 메서드 대신 InitializeComponent .resx 파일로 직렬화됩니다.

자세한 내용은 특성을 참조하세요.

생성자

DesignOnlyAttribute(Boolean)

DesignOnlyAttribute 클래스의 새 인스턴스를 초기화합니다.

필드

Default

DesignOnlyAttribute의 기본값인 No을 지정합니다. 이 static 필드는 읽기 전용입니다.

No

속성을 디자인 타임 또는 런타임에서 설정할 수 있도록 지정합니다. 이 static 필드는 읽기 전용입니다.

Yes

속성을 디자인 타임에서만 설정할 수 있도록 지정합니다. 이 static 필드는 읽기 전용입니다.

속성

IsDesignOnly

속성을 디자인 타임에서만 설정할 수 있는지 여부를 나타내는 값을 가져옵니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

주어진 개체의 값이 현재 DesignOnlyAttribute와 같은지 여부를 반환합니다.

GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

이 특성이 기본값인지 여부를 확인합니다.

IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보