EditorBrowsableAttribute Classe

Definizione

Specifica che una classe o un membro è visualizzabile in un editor. La classe non può essere ereditata.

public ref class EditorBrowsableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct)]
public sealed class EditorBrowsableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct)>]
type EditorBrowsableAttribute = class
    inherit Attribute
Public NotInheritable Class EditorBrowsableAttribute
Inherits Attribute
Ereditarietà
EditorBrowsableAttribute
Attributi

Esempio

Nell'esempio seguente viene illustrato come nascondere una proprietà di una classe da IntelliSense impostando il valore appropriato per l'attributo EditorBrowsableAttribute .

Compilare Class1 nel proprio assembly. In Visual Studio creare quindi un nuovo progetto e aggiungere un riferimento all'assembly contenente Class1. Dichiarare un'istanza di Class1e quindi immettere il nome dell'istanza e premere il tasto . per attivare l'elenco intelliSense dei Class1 membri. La Age proprietà non viene visualizzata nell'elenco a discesa perché è nascosta.

#using <system.dll>

using namespace System;
using namespace System::ComponentModel;

namespace EditorBrowsableDemo
{
   public ref class Class1
   {
   public:
      Class1()
      { 
         //
         // TODO: Add constructor logic here
         //
      }

   private:
      int ageval;

   public:
      [EditorBrowsable(EditorBrowsableState::Never)]
      property int Age 
      {
         int get()
         {
            return ageval;
         }

         void set( int value )
         {
            if ( ageval != value )
            {
               ageval = value;
            }
         }
      }
   };
}
using System.ComponentModel;

namespace EditorBrowsableDemo;

public class Class1
{
    public Class1() { }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public int Age
    {
        get; set;
    }

    public int Height
    {
        get; set;
    }
}
Imports System.ComponentModel

Public Class Class1

    Private ageval As Integer

    <EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    Public Property Age() As Integer

        Get
            Return ageval
        End Get

        Set(ByVal Value As Integer)
            If Not ageval.Equals(Value) Then
                ageval = Value
            End If
        End Set

    End Property

End Class

Commenti

EditorBrowsableAttribute è un hint per una finestra di progettazione che indica se deve essere visualizzata una classe o un membro. È possibile usare questo tipo in una finestra di progettazione visiva o in un editor di testo per determinare cosa rendere visibile all'utente. Ad esempio, il motore IntelliSense in Visual Studio usa questo attributo per determinare se visualizzare una classe o un membro.

In Visual Studio è possibile controllare quando vengono visualizzate proprietà avanzate in C# IntelliSense e le Finestra Proprietà con l'impostazione < in Tools Options Text Editor C#. Il corrispondente EditorBrowsableState è Advanced.

Annotazioni

In C#, non impedisce EditorBrowsableAttribute l'esplorazione dei membri da parte di una classe nello stesso assembly.

Costruttori

Nome Descrizione
EditorBrowsableAttribute()

Inizializza una nuova istanza della EditorBrowsableAttribute classe con State impostato sullo stato predefinito.

EditorBrowsableAttribute(EditorBrowsableState)

Inizializza una nuova istanza della EditorBrowsableAttribute classe con un oggetto EditorBrowsableState.

Proprietà

Nome Descrizione
State

Ottiene lo stato esplorabile della proprietà o del metodo .

TypeId

Se implementato in una classe derivata, ottiene un identificatore univoco per questo Attribute.

(Ereditato da Attribute)

Metodi

Nome Descrizione
Equals(Object)

Restituisce un valore che indica se il valore dell'oggetto specificato è uguale all'oggetto corrente EditorBrowsableAttribute.

GetHashCode()

Restituisce il codice hash per questa istanza.

GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

Quando sottoposto a override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.

(Ereditato da Attribute)
Match(Object)

Quando sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

Nome Descrizione
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto .

(Ereditato da Attribute)

Si applica a

Vedi anche