DebuggerTypeProxyAttribute Конструкторы

Определение

Инициализирует новый экземпляр класса DebuggerTypeProxyAttribute, используя указанный прокси-тип.

Перегрузки

DebuggerTypeProxyAttribute(String)

Инициализирует новый экземпляр класса DebuggerTypeProxyAttribute, используя указанное имя прокси-типа.

DebuggerTypeProxyAttribute(Type)

Инициализирует новый экземпляр класса DebuggerTypeProxyAttribute, используя указанный прокси-тип.

DebuggerTypeProxyAttribute(String)

Исходный код:
DebuggerTypeProxyAttribute.cs
Исходный код:
DebuggerTypeProxyAttribute.cs
Исходный код:
DebuggerTypeProxyAttribute.cs

Инициализирует новый экземпляр класса DebuggerTypeProxyAttribute, используя указанное имя прокси-типа.

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

Параметры

typeName
String

Имя прокси-типа.

Комментарии

Отладчик создает новый экземпляр класса прокси-типа всякий раз, когда требуется отобразить переменную конечного типа. Это может сказываться на производительности. Поэтому не следует выполнять в конструкторе больше действий, чем это действительно необходимо.

Применяется к

DebuggerTypeProxyAttribute(Type)

Исходный код:
DebuggerTypeProxyAttribute.cs
Исходный код:
DebuggerTypeProxyAttribute.cs
Исходный код:
DebuggerTypeProxyAttribute.cs

Инициализирует новый экземпляр класса DebuggerTypeProxyAttribute, используя указанный прокси-тип.

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

Параметры

type
Type

Прокси-тип.

Исключения

type имеет значение null.

Примеры

В следующем примере кода показано использование конструктора DebuggerTypeProxyAttribute(Type) для указания прокси-сервера отображения отладчика. Этот пример входит в состав более крупного примера использования класса DebuggerDisplayAttribute.

[DebuggerTypeProxy(HashtableDebugView::typeid)]
ref class MyHashtable : Hashtable
{
private:
    static const String^ TestString = "This should not appear in the debug window.";

internal:
    ref class HashtableDebugView
    {
    private:
        Hashtable^ hashtable;
    public:
        static const String^ TestString = "This should appear in the debug window.";
        HashtableDebugView(Hashtable^ hashtable)
        {
            this->hashtable = hashtable;
        }

        [DebuggerBrowsable(DebuggerBrowsableState::RootHidden)]
        property array<KeyValuePairs^>^ Keys
        {
            array<KeyValuePairs^>^ get()
            {
                array<KeyValuePairs^>^ keys = gcnew array<KeyValuePairs^>(hashtable->Count);

                IEnumerator^ ie = hashtable->Keys->GetEnumerator();
                int i = 0;
                Object^ key;
                while (ie->MoveNext())
                {
                    key = ie->Current;
                    keys[i] = gcnew KeyValuePairs(hashtable, key, hashtable[key]);
                    i++;
                }
                return keys;
            }
        }
    };
};
[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

Комментарии

Отладчик создает новый экземпляр класса прокси-типа всякий раз, когда требуется отобразить переменную конечного типа. Это может сказываться на производительности. Поэтому не следует выполнять в конструкторе больше действий, чем это действительно необходимо.

Применяется к