DebuggerTypeProxyAttribute Constructeurs

Définition

Initialise une nouvelle instance de la DebuggerTypeProxyAttribute classe à l’aide du type du proxy.

Surcharges

Nom Description
DebuggerTypeProxyAttribute(String)

Initialise une nouvelle instance de la DebuggerTypeProxyAttribute classe à l’aide du nom de type du proxy.

DebuggerTypeProxyAttribute(Type)

Initialise une nouvelle instance de la DebuggerTypeProxyAttribute classe à l’aide du type du proxy.

DebuggerTypeProxyAttribute(String)

Initialise une nouvelle instance de la DebuggerTypeProxyAttribute classe à l’aide du nom de type du proxy.

public:
 DebuggerTypeProxyAttribute(System::String ^ typeName);
public DebuggerTypeProxyAttribute(string typeName);
new System.Diagnostics.DebuggerTypeProxyAttribute : string -> System.Diagnostics.DebuggerTypeProxyAttribute
Public Sub New (typeName As String)

Paramètres

typeName
String

Nom du type du type proxy.

Remarques

Le débogueur crée une nouvelle instance de la classe de proxy de type chaque fois qu’il doit afficher une variable du type visé. Cela peut avoir des implications sur les performances. Par conséquent, vous ne devez pas faire plus de travail dans le constructeur que absolument nécessaire.

S’applique à

DebuggerTypeProxyAttribute(Type)

Initialise une nouvelle instance de la DebuggerTypeProxyAttribute classe à l’aide du type du proxy.

public:
 DebuggerTypeProxyAttribute(Type ^ type);
public DebuggerTypeProxyAttribute(Type type);
new System.Diagnostics.DebuggerTypeProxyAttribute : Type -> System.Diagnostics.DebuggerTypeProxyAttribute
Public Sub New (type As Type)

Paramètres

type
Type

Type de proxy.

Exceptions

type a la valeur null.

Exemples

L’exemple de code suivant montre l’utilisation du DebuggerTypeProxyAttribute(Type) constructeur pour spécifier un proxy d’affichage du débogueur. Cet exemple de code fait partie d’un exemple plus grand fourni pour la DebuggerDisplayAttribute classe.

[DebuggerTypeProxy(typeof(HashtableDebugView))]
class MyHashtable : Hashtable
{
    private const string TestString = "This should not appear in the debug window.";

    internal class HashtableDebugView
    {
        private Hashtable hashtable;
        public const string TestString = "This should appear in the debug window.";
        public HashtableDebugView(Hashtable hashtable)
        {
            this.hashtable = hashtable;
        }

        [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
        public KeyValuePairs[] Keys
        {
            get
            {
                KeyValuePairs[] keys = new KeyValuePairs[hashtable.Count];

                int i = 0;
                foreach(object key in hashtable.Keys)
                {
                    keys[i] = new KeyValuePairs(hashtable, key, hashtable[key]);
                    i++;
                }
                return keys;
            }
        }
    }
}
<DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(GetType(MyHashtable.HashtableDebugView))> _
Class MyHashtable
    Inherits Hashtable
    Private Const TestString As String = "This should not appear in the debug window."

    Friend Class HashtableDebugView
        Private hashtable As Hashtable
        Public Shared TestString As String = "This should appear in the debug window."

        Public Sub New(ByVal hashtable As Hashtable)
            Me.hashtable = hashtable
        End Sub

        <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)> _
        ReadOnly Property Keys as KeyValuePairs()
            Get
                Dim nkeys(hashtable.Count) as KeyValuePairs

                Dim i as Integer = 0
                For Each key As Object In hashtable.Keys
                    nkeys(i) = New KeyValuePairs(hashtable, key, hashtable(key))
                    i = i + 1
                Next
                Return nkeys
            End Get
        End Property

    End Class
End Class

Remarques

Le débogueur crée une nouvelle instance de la classe de proxy de type chaque fois qu’il doit afficher une variable du type visé. Cela peut avoir des implications sur les performances. Par conséquent, vous ne devez pas faire plus de travail dans le constructeur que absolument nécessaire.

S’applique à