TraceSource.GetSupportedAttributes 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
추적 소스에서 지원하는 사용자 지정 특성을 가져옵니다.
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
설명
반환null에 대한 GetSupportedAttributes 기본 구현입니다.
상속자 참고
클래스 또는 파생 클래스에서 상속하는 경우 메서드를 재정의 TraceSource GetSupportedAttributes() 하여 클래스에 대한 사용자 지정 특성을 제공할 수 있습니다.