TraceSource.Attributes Egenskap

Definition

Hämtar de anpassade växelattribut som definierats i programkonfigurationsfilen.

public:
 property System::Collections::Specialized::StringDictionary ^ Attributes { System::Collections::Specialized::StringDictionary ^ get(); };
public System.Collections.Specialized.StringDictionary Attributes { get; }
member this.Attributes : System.Collections.Specialized.StringDictionary
Public ReadOnly Property Attributes As StringDictionary

Egenskapsvärde

En StringDictionary som innehåller anpassade attribut för spårningsväxeln.

Exempel

Följande kodexempel visar hur du visar anpassade attribut för en TraceSource. Det här kodexemplet är en del av ett större exempel för TraceSource klassen.

// Get the custom attributes for the TraceSource.
Console.WriteLine("Number of custom trace source attributes = "
    + ts.Attributes.Count);
foreach (DictionaryEntry de in ts.Attributes)
    Console.WriteLine("Custom trace source attribute = "
        + de.Key + "  " + de.Value);
' Get the custom attributes for the TraceSource.
Console.WriteLine("Number of custom trace source attributes = " + ts.Attributes.Count)
Dim de As DictionaryEntry
For Each de In ts.Attributes
    Console.WriteLine("Custom trace source attribute = " + de.Key + "  " + de.Value)
Next de

Kommentarer

Egenskapen Attributes identifierar de anpassade attribut som refereras till i programmets konfigurationsfil. Orefererade anpassade attribut räknas inte upp. Klasser som ärver från TraceSource klassen kan lägga till anpassade attribut genom att Switch.GetSupportedAttributes åsidosätta metoden och returnera en strängmatris med anpassade attributnamn.

Följande är ett exempel på ett spårningskällaelement som anger det anpassade attributet SecondTraceSourceAttribute:

<sources>
  <source name="TraceTest" switchName="TestSourceSwitch"
    switchType="Testing.MySourceSwitch, TraceSample"
    SecondTraceSourceAttribute="two">
  </source>
</sources>

Gäller för