Share via


TraceSource.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 를 보여 주는 메서드에 대 한 MyTraceSource 사용자 지정 특성을 식별 하는 클래스입니다.

public class MyTraceSource : TraceSource
{
    string firstAttribute = "";
    string secondAttribute = "";
    public MyTraceSource(string n) : base(n) {}

    public string FirstTraceSourceAttribute
    {
        get {
            foreach (DictionaryEntry de in this.Attributes)
                if (de.Key.ToString().ToLower() == "firsttracesourceattribute")
                    firstAttribute = de.Value.ToString() ;
            return firstAttribute;
        }
        set { firstAttribute = value; }
    }

    public string SecondTraceSourceAttribute
    {
        get {
            foreach (DictionaryEntry de in this.Attributes)
                if (de.Key.ToString().ToLower() == "secondtracesourceattribute")
                    secondAttribute = de.Value.ToString();
            return secondAttribute; }
        set { secondAttribute = value; }
    }

    protected override string[] GetSupportedAttributes()
    {
        // Allow the use of the attributes in the configuration file.
        return new string[] { "FirstTraceSourceAttribute", "SecondTraceSourceAttribute" };
    }
}
Public Class MyTraceSource
    Inherits TraceSource
    Private firstAttribute As String = ""
    Private secondAttribute As String = ""

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

    End Sub

    Public Property FirstTraceSourceAttribute() As String
        Get
            Dim de As DictionaryEntry
            For Each de In Me.Attributes
                If de.Key.ToString().ToLower() = "firsttracesourceattribute" Then
                    firstAttribute = de.Value.ToString()
                End If
            Next de
            Return firstAttribute
        End Get
        Set(ByVal value As String)
            firstAttribute = value
        End Set
    End Property

    Public Property SecondTraceSourceAttribute() As String
        Get
            Dim de As DictionaryEntry
            For Each de In Me.Attributes
                If de.Key.ToString().ToLower() = "secondtracesourceattribute" Then
                    secondAttribute = de.Value.ToString()
                End If
            Next de
            Return secondAttribute
        End Get
        Set(ByVal value As String)
            secondAttribute = Value
        End Set
    End Property

    Protected Overrides Function GetSupportedAttributes() As String()
        ' Allow the use of the attributes in the configuration file.
        Return New String() {"FirstTraceSourceAttribute", "SecondTraceSourceAttribute"}

    End Function 'GetSupportedAttributes
End Class

설명

에 대한 GetSupportedAttributes 기본 구현은 를 반환합니다 null.

상속자 참고

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

적용 대상