TraceSource.GetSupportedAttributes Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene gli attributi personalizzati supportati dall'origine di traccia.
protected public:
virtual cli::array <System::String ^> ^ GetSupportedAttributes();
protected:
virtual cli::array <System::String ^> ^ GetSupportedAttributes();
protected internal virtual string[] GetSupportedAttributes();
protected virtual string[] GetSupportedAttributes();
abstract member GetSupportedAttributes : unit -> string[]
override this.GetSupportedAttributes : unit -> string[]
Protected Friend Overridable Function GetSupportedAttributes () As String()
Protected Overridable Function GetSupportedAttributes () As String()
Valori restituiti
Matrice di stringhe che denomina gli attributi personalizzati supportati dall'origine di traccia o null se non sono presenti attributi personalizzati.
Esempio
Nell'esempio di codice seguente viene illustrato un override del GetSupportedAttributes metodo per identificare gli attributi personalizzati per la MyTraceSource classe .
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
Commenti
L'implementazione predefinita per GetSupportedAttributes restituisce null.
Note per gli eredi
Quando ereditano dalla TraceSource classe o da una classe derivata, è possibile eseguire l'override del GetSupportedAttributes() metodo per fornire attributi personalizzati per la classe.