AttributeCollection 클래스

정의

특성 컬렉션을 나타냅니다.

public ref class AttributeCollection : System::Collections::ICollection
public class AttributeCollection : System.Collections.ICollection
[System.Runtime.InteropServices.ComVisible(true)]
public class AttributeCollection : System.Collections.ICollection
type AttributeCollection = class
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(true)>]
type AttributeCollection = class
    interface ICollection
    interface IEnumerable
Public Class AttributeCollection
Implements ICollection
상속
AttributeCollection
특성
구현

예제

첫 번째 코드 예제를 확인 여부를 BrowsableAttribute 이 컬렉션에 설정 되어 있습니다. 두 번째 코드 예제에서는 실제 값을 가져옵니다는 DescriptionAttribute 단추에 대 한 합니다. 두 예제에서는 button1textBox1 폼에 만들었습니다. 특성을 사용 하는 경우에 특성에 설정 되어 있거나이 해당 값에 액세스 하는 확인 합니다.

private:
   void ContainsAttribute()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Sets an Attribute to the specific attribute.
      BrowsableAttribute^ myAttribute = BrowsableAttribute::Yes;

      if ( attributes->Contains( myAttribute ) )
      {
         textBox1->Text = "button1 has a browsable attribute.";
      }
      else
      {
         textBox1->Text = "button1 does not have a browsable attribute.";
      }
   }
private void ContainsAttribute() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Sets an Attribute to the specific attribute.
    BrowsableAttribute myAttribute = BrowsableAttribute.Yes;

    if (attributes.Contains(myAttribute))
       textBox1.Text = "button1 has a browsable attribute.";
    else
       textBox1.Text = "button1 does not have a browsable attribute.";
 }
Private Sub ContainsAttribute()
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    
    ' Sets an Attribute to the specific attribute.
    Dim myAttribute As BrowsableAttribute = BrowsableAttribute.Yes
    
    If attributes.Contains(myAttribute) Then
        textBox1.Text = "button1 has a browsable attribute."
    Else
        textBox1.Text = "button1 does not have a browsable attribute."
    End If
End Sub
private:
   void GetAttributeValue()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Gets the designer attribute from the collection.
      DesignerAttribute^ myDesigner;
      myDesigner = (DesignerAttribute^)(attributes[DesignerAttribute::typeid]);
      
      // Prints the value of the attribute in a text box.
      textBox1->Text = myDesigner->DesignerTypeName;
   }
private void GetAttributeValue() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Gets the designer attribute from the collection.
    DesignerAttribute myDesigner;
    myDesigner = (DesignerAttribute)attributes[typeof(DesignerAttribute)];

    // Prints the value of the attribute in a text box.
    textBox1.Text = myDesigner.DesignerTypeName;
 }
Private Sub GetAttributeValue()
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)
    
    ' Gets the designer attribute from the collection.
    Dim myDesigner As DesignerAttribute
    myDesigner = CType(attributes(GetType(DesignerAttribute)), DesignerAttribute)
    
    ' Prints the value of the attribute in a text box.
    textBox1.Text = myDesigner.DesignerTypeName
End Sub

설명

AttributeCollection 클래스는 읽기 전용으로, 추가 하거나 특성을 제거 하는 메서드를 구현 하지 않습니다. 이러한 메서드를 구현 하려면이 클래스에서 상속 해야 합니다.

사용 하 여는 Count 속성을 컬렉션에 존재 하는 특성 수를 찾습니다.

또한 컬렉션의 내용에 대해 쿼리를이 클래스의 메서드를 사용할 수 있습니다. 호출 된 Contains 지정 된 특성 또는 특성 배열이 컬렉션에 있는지 확인 하는 방법입니다. 호출 된 Matches 지정 된 특성 또는 특성 배열이 컬렉션에 있는지, 그리고 지정된 된 특성의 값 컬렉션에 있는 값과 동일한 지 확인 하는 메서드.

대부분의 특성에 기본값이 있는 동안에 기본값이 필요 하지 않습니다. 특성에 기본값이 없는 경우 null 형식을 사용 하는 인덱싱된 속성에서 반환 됩니다. 사용자 지정 특성을 정의할 때 기본 값을 "Default" 라는 특성 형식의 공용 정적 필드를 정의 하거나 인수를 사용 하지 않는 생성자를 제공 하 여 선언할 수 있습니다.

생성자

AttributeCollection()

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

AttributeCollection(Attribute[])

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

필드

Empty

새 컬렉션을 만드는 대신 사용할 수 있는 빈 컬렉션을 지정합니다. 이 필드는 읽기 전용입니다.

속성

Attributes

특성 컬렉션을 가져옵니다.

Count

특성의 개수를 가져옵니다.

Item[Int32]

지정된 인덱스 번호가 있는 특성을 가져옵니다.

Item[Type]

지정된 형식의 특성을 가져옵니다.

메서드

Contains(Attribute)

이 특성 컬렉션에 지정된 특성이 있는지 확인합니다.

Contains(Attribute[])

이 특성 컬렉션에 특성 배열의 지정된 특성이 모두 포함되어 있는지 확인합니다.

CopyTo(Array, Int32)

컬렉션을 지정된 인덱스에서 시작하여 배열에 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
FromExisting(AttributeCollection, Attribute[])

기존 AttributeCollection에서 새 AttributeCollection을 만듭니다.

GetDefaultAttribute(Type)

지정된 Attribute의 기본 Type를 반환합니다.

GetEnumerator()

이 컬렉션의 열거자를 가져옵니다.

GetHashCode()

기본 해시 함수로 작동합니다.

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

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

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

지정된 특성이 컬렉션의 특성과 같은지 확인합니다.

Matches(Attribute[])

지정된 배열의 특성이 컬렉션의 특성과 같은지 확인합니다.

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.Count

컬렉션에 포함된 요소 수를 가져옵니다.

ICollection.IsSynchronized

해당 컬렉션에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다.

ICollection.SyncRoot

컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

IEnumerable.GetEnumerator()

IEnumeratorIDictionary를 반환합니다.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보