Switch.GetSupportedAttributes 메서드

정의

스위치에서 지원하는 사용자 지정 특성을 가져옵니다.

protected:
 virtual cli::array <System::String ^> ^ GetSupportedAttributes();
protected public:
 virtual cli::array <System::String ^> ^ GetSupportedAttributes();
protected virtual string[]? GetSupportedAttributes ();
protected virtual string[] GetSupportedAttributes ();
protected internal virtual string[] GetSupportedAttributes ();
abstract member GetSupportedAttributes : unit -> string[]
override this.GetSupportedAttributes : unit -> string[]
Protected Overridable Function GetSupportedAttributes () As String()
Protected Friend Overridable Function GetSupportedAttributes () As String()

반환

String[]

스위치에서 지원하는 사용자 지정 특성의 이름이 들어 있는 문자열 배열을 반환하며, 지원되는 사용자 지정 특성이 없으면 null을 반환합니다.

예제

다음 코드 샘플에서는 사용자 지정 스위치에 대한 메서드의 GetSupportedAttributes 재정의를 보여줍니다.

public class MySourceSwitch : SourceSwitch
{
    int sourceAttribute = 0;
    public MySourceSwitch(string n) : base(n) { }
    public int CustomSourceSwitchAttribute
    {
        get
        {
            foreach (DictionaryEntry de in this.Attributes)
                if (de.Key.ToString().ToLower() == "customsourceswitchattribute")
                    sourceAttribute = (int)de.Value;
            return sourceAttribute;
        }
        set { sourceAttribute = (int)value; }
    }

    protected override string[] GetSupportedAttributes()
    {
        return new string[] { "customsourceSwitchattribute" };
    }
}
Public Class MySourceSwitch
    Inherits SourceSwitch
    Private sourceAttribute As Integer = 0

    Public Sub New(ByVal n As String)
        MyBase.New(n)

    End Sub

    Public Property CustomSourceSwitchAttribute() As Integer
        Get
            Dim de As DictionaryEntry
            For Each de In Me.Attributes
                If de.Key.ToString().ToLower() = "customsourceswitchattribute" Then
                    sourceAttribute = Fix(de.Value)
                End If
            Next de
            Return sourceAttribute
        End Get
        Set(ByVal value As Integer)
            sourceAttribute = Fix(Value)
        End Set
    End Property

    Protected Overrides Function GetSupportedAttributes() As String()
        Return New String() {"customsourceSwitchattribute"}

    End Function 'GetSupportedAttributes
End Class

설명

메서드의 기본 구현은 를 GetSupportedAttributes 반환합니다 null. 스위치가 구성 파일에 추가되고 에서 반환 GetSupportedAttributesConfigurationException 하는 문자열 배열에 포함되지 않은 사용자 지정 특성이 지정되면 스위치가 로드될 때 이 throw됩니다.

상속자 참고

클래스 또는 파생 클래스에서 Switch 상속하는 경우 메서드를 재정의 GetSupportedAttributes() 하여 클래스에 대한 사용자 지정 특성을 제공할 수 있습니다.

적용 대상