DesignOnlyAttribute 클래스

정의

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

public ref class DesignOnlyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class DesignOnlyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
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.
        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 . 그런 다음, 이 속성에 대한 특성을 반환하고 특성 변수에 저장합니다.

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

// 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입니다.

해당 값이 DesignOnlyAttribute 메서드 대신 InitializeComponent .resx 파일로 직렬화되도록 설정된 true 속성입니다.

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

생성자

Name Description
DesignOnlyAttribute(Boolean)

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

필드

Name Description
Default

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

No

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

Yes

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

속성

Name Description
IsDesignOnly

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

TypeId

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

(다음에서 상속됨 Attribute)

메서드

Name Description
Equals(Object)

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

GetHashCode()

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

GetType()

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

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

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

Match(Object)

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

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

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

Name Description
_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)

적용 대상

추가 정보