AttributeCollection.Matches 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 특성 또는 특성 배열이 컬렉션의 특성 또는 특성 배열과 같은지 여부를 확인합니다.
오버로드
| Name | Description |
|---|---|
| Matches(Attribute) |
지정된 특성이 컬렉션의 특성과 같은지 여부를 확인합니다. |
| Matches(Attribute[]) |
지정된 배열의 특성이 컬렉션의 특성과 같은지 여부를 확인합니다. |
Matches(Attribute)
지정된 특성이 컬렉션의 특성과 같은지 여부를 확인합니다.
public:
bool Matches(Attribute ^ attribute);
public bool Matches(Attribute attribute);
member this.Matches : Attribute -> bool
Public Function Matches (attribute As Attribute) As Boolean
매개 변수
반품
true특성이 컬렉션 내에 포함되어 있고 컬렉션의 특성과 동일한 값을 가지고 있으면 이고, 그렇지 않으면 . false
예제
다음 코드 예제에서는 컬렉션의 멤버이며 컬렉션이 로 설정되었는지 확인 BrowsableAttribute 합니다 true. 폼에서 생성된 것으로 button1textBox1 가정합니다.
private:
void MatchesAttribute()
{
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection^ attributes;
attributes = TypeDescriptor::GetAttributes( button1 );
// Checks to see if the browsable attribute is true.
if ( attributes->Matches( BrowsableAttribute::Yes ) )
{
textBox1->Text = "button1 is browsable.";
}
else
{
textBox1->Text = "button1 is not browsable.";
}
}
private void MatchesAttribute() {
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection attributes;
attributes = TypeDescriptor.GetAttributes(button1);
// Checks to see if the browsable attribute is true.
if (attributes.Matches(BrowsableAttribute.Yes))
textBox1.Text = "button1 is browsable.";
else
textBox1.Text = "button1 is not browsable.";
}
Private Sub MatchesAttribute
' Creates a new collection and assigns it the attributes for button
Dim attributes As AttributeCollection
attributes = TypeDescriptor.GetAttributes(button1)
' Checks to see if the browsable attribute is true.
If attributes.Matches(BrowsableAttribute.Yes) Then
textBox1.Text = "button1 is browsable."
Else
textBox1.Text = "button1 is not browsable."
End If
End Sub
설명
특성은 일치를 지원할 수 있습니다.
메서드와 Contains 메서드의 Matches 차이점은 특성에서 메서드를 Match 호출하고 Contains 메서드를 호출한다는 Matches 것입니다Equals.
대부분의 특성에서 이러한 메서드는 동일한 작업을 수행합니다. 그러나 Match 여러 플래그가 있을 수 있는 특성의 경우 일반적으로 구현되므로 플래그가 충족되면 반환 true 됩니다. 예를 들어 부울 플래그 "SupportsSql", "SupportsOleDb" 및 "SupportsXml"이 있는 데이터 바인딩 특성을 고려합니다. 이 특성은 세 가지 데이터 바인딩 방법을 모두 지원하는 속성에 있을 수 있습니다. 프로그래머가 특정 접근 방식을 사용할 수 있는 경우에만 알고 있어야 하는 경우가 많으며, 세 가지 모두 알 수 있는 것은 아닙니다. 따라서 프로그래머가 프로그래머에 필요한 플래그만 포함하는 특성 인스턴스와 함께 사용할 Match 수 있습니다.
추가 정보
적용 대상
Matches(Attribute[])
지정된 배열의 특성이 컬렉션의 특성과 같은지 여부를 확인합니다.
public:
bool Matches(cli::array <Attribute ^> ^ attributes);
public bool Matches(Attribute[] attributes);
member this.Matches : Attribute[] -> bool
Public Function Matches (attributes As Attribute()) As Boolean
매개 변수
- attributes
- Attribute[]
이 컬렉션의 MemberAttributes 특성과 비교할 배열입니다.
반품
true배열의 모든 특성이 컬렉션에 포함되어 있고 컬렉션의 특성과 동일한 값을 가지면 이고, 그렇지 않으면 . false
예제
다음 코드 예제에서는 단추와 텍스트 상자의 특성을 비교하여 일치하는지 확인합니다. 폼에서 생성된 것으로 button1textBox1 가정합니다.
private:
void MatchesAttributes()
{
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection^ myCollection;
myCollection = TypeDescriptor::GetAttributes( button1 );
// Checks to see whether the attributes in myCollection match the attributes for textBox1.
array<Attribute^>^ myAttrArray = gcnew array<Attribute^>(100);
TypeDescriptor::GetAttributes( textBox1 )->CopyTo( myAttrArray, 0 );
if ( myCollection->Matches( myAttrArray ) )
{
textBox1->Text = "The attributes in the button and text box match.";
}
else
{
textBox1->Text = "The attributes in the button and text box do not match.";
}
}
private void MatchesAttributes() {
// Creates a new collection and assigns it the attributes for button1.
AttributeCollection myCollection;
myCollection = TypeDescriptor.GetAttributes(button1);
// Checks to see whether the attributes in myCollection match the attributes for textBox1.
Attribute[] myAttrArray = new Attribute[100];
TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0);
if (myCollection.Matches(myAttrArray))
textBox1.Text = "The attributes in the button and text box match.";
else
textBox1.Text = "The attributes in the button and text box do not match.";
}
Private Sub MatchesAttributes()
' Creates a new collection and assigns it the attributes for button1.
Dim myCollection As AttributeCollection
myCollection = TypeDescriptor.GetAttributes(button1)
' Checks to see whether the attributes in myCollection match the attributes.
' for textBox1.
Dim myAttrArray(100) As Attribute
TypeDescriptor.GetAttributes(textBox1).CopyTo(myAttrArray, 0)
If myCollection.Matches(myAttrArray) Then
textBox1.Text = "The attributes in the button and text box match."
Else
textBox1.Text = "The attributes in the button and text box do not match."
End If
End Sub
설명
특성은 일치를 지원할 수 있습니다.