TypeDescriptor.GetProperties 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.
Restituisce l'insieme di proprietà di un componente o di un tipo.
Overload
| Nome | Descrizione |
|---|---|
| GetProperties(Object) |
Restituisce l'insieme di proprietà per un componente specificato. |
| GetProperties(Type) |
Restituisce l'insieme di proprietà per un tipo di componente specificato. |
| GetProperties(Object, Attribute[]) |
Restituisce la raccolta di proprietà per un componente specificato utilizzando una matrice di attributi specificata come filtro. |
| GetProperties(Object, Boolean) |
Restituisce la raccolta di proprietà per un componente specificato utilizzando il descrittore di tipo predefinito. |
| GetProperties(Type, Attribute[]) |
Restituisce la raccolta di proprietà per un tipo specificato di componente utilizzando una matrice di attributi specificata come filtro. |
| GetProperties(Object, Attribute[], Boolean) |
Restituisce la raccolta di proprietà per un componente specificato utilizzando una matrice di attributi specificata come filtro e utilizzando un descrittore di tipo personalizzato. |
GetProperties(Object)
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce l'insieme di proprietà per un componente specificato.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")>]
static member GetProperties : obj -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : obj -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object) As PropertyDescriptorCollection
Parametri
- component
- Object
Componente per cui ottenere le proprietà.
Valori restituiti
Oggetto PropertyDescriptorCollection con le proprietà per il componente specificato.
- Attributi
Eccezioni
component è un oggetto remoto tra processi.
Esempio
Nell'esempio di codice seguente viene illustrato l'uso del GetProperties metodo per accedere alle proprietà di un controllo . Questo esempio di codice fa parte di un esempio più ampio fornito per la ComponentDesigner classe .
// This is the shadowed property on the designer.
// This value will be serialized instead of the
// value of the control's property.
public Color BackColor
{
get => (Color)ShadowProperties[nameof(BackColor)];
set
{
if (changeService != null)
{
PropertyDescriptor backColorDesc =
TypeDescriptor.GetProperties(Control)["BackColor"];
changeService.OnComponentChanging(
Control,
backColorDesc);
ShadowProperties[nameof(BackColor)] = value;
changeService.OnComponentChanged(
Control,
backColorDesc,
null,
null);
}
}
}
' This is the shadowed property on the designer.
' This value will be serialized instead of the
' value of the control's property.
Public Property BackColor() As Color
Get
Return CType(ShadowProperties("BackColor"), Color)
End Get
Set(ByVal value As Color)
If (Me.changeService IsNot Nothing) Then
Dim backColorDesc As PropertyDescriptor = TypeDescriptor.GetProperties(Me.Control)("BackColor")
Me.changeService.OnComponentChanging(Me.Control, backColorDesc)
Me.ShadowProperties("BackColor") = value
Me.changeService.OnComponentChanged(Me.Control, backColorDesc, Nothing, Nothing)
End If
End Set
End Property
Commenti
Le proprietà di un componente possono differire dalle proprietà di una classe, perché il sito può aggiungere o rimuovere proprietà se il componente è presente nel sito.
Se il component parametro è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
Si applica a
GetProperties(Type)
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce l'insieme di proprietà per un tipo di componente specificato.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(Type ^ componentType);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(Type componentType);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(Type componentType);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")>]
static member GetProperties : Type -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : Type -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (componentType As Type) As PropertyDescriptorCollection
Parametri
Valori restituiti
Oggetto PropertyDescriptorCollection con le proprietà per un tipo di componente specificato.
- Attributi
Commenti
Chiamare questa versione di questo metodo solo quando non si dispone di un'istanza dell'oggetto .
Se il componentType parametro è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
Si applica a
GetProperties(Object, Attribute[])
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce la raccolta di proprietà per un componente specificato utilizzando una matrice di attributi specificata come filtro.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, cli::array <Attribute ^> ^ attributes);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")>]
static member GetProperties : obj * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : obj * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, attributes As Attribute()) As PropertyDescriptorCollection
Parametri
- component
- Object
Componente per cui ottenere le proprietà.
Valori restituiti
Oggetto PropertyDescriptorCollection con le proprietà che corrispondono agli attributi specificati per il componente specificato.
- Attributi
Eccezioni
component è un oggetto remoto tra processi.
Esempio
Nell'esempio di codice seguente viene illustrato come implementare il GetProperties metodo . Questo esempio di codice fa parte di un esempio più ampio fornito per la PropertyTab classe .
// Returns the properties of the specified component extended with
// a CategoryAttribute reflecting the name of the type of the property.
[ReflectionPermission(SecurityAction::Demand, Flags=ReflectionPermissionFlag::MemberAccess)]
virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component, array<System::Attribute^>^attributes ) override
{
PropertyDescriptorCollection^ props;
if ( attributes == nullptr )
props = TypeDescriptor::GetProperties( component );
else
props = TypeDescriptor::GetProperties( component, attributes );
array<PropertyDescriptor^>^propArray = gcnew array<PropertyDescriptor^>(props->Count);
for ( int i = 0; i < props->Count; i++ )
{
// Create a new PropertyDescriptor from the old one, with
// a CategoryAttribute matching the name of the type.
array<Attribute^>^temp0 = {gcnew CategoryAttribute( props[ i ]->PropertyType->Name )};
propArray[ i ] = TypeDescriptor::CreateProperty( props[ i ]->ComponentType, props[ i ], temp0 );
}
return gcnew PropertyDescriptorCollection( propArray );
}
virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component ) override
{
return this->GetProperties( component, nullptr );
}
// Returns the properties of the specified component extended with
// a CategoryAttribute reflecting the name of the type of the property.
public override PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes)
{
PropertyDescriptorCollection props = attributes == null ? TypeDescriptor.GetProperties(component) : TypeDescriptor.GetProperties(component, attributes);
PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count];
for (int i = 0; i < props.Count; i++)
{
// Create a new PropertyDescriptor from the old one, with
// a CategoryAttribute matching the name of the type.
propArray[i] = TypeDescriptor.CreateProperty(props[i].ComponentType, props[i], new CategoryAttribute(props[i].PropertyType.Name));
}
return new PropertyDescriptorCollection(propArray);
}
public override PropertyDescriptorCollection GetProperties(object component) => GetProperties(component, null);
Commenti
Le proprietà per il component parametro possono differire dalle proprietà di una classe, perché il sito può aggiungere o rimuovere proprietà se il component parametro è sito.
La attributes matrice di parametri viene usata per filtrare la matrice. Il filtro è definito dalle regole seguenti:
Se una proprietà non dispone di una Attribute classe della stessa classe, la proprietà non viene inclusa nella matrice restituita.
Se l'attributo è un'istanza della Attribute classe , la proprietà deve essere una corrispondenza esatta o non è inclusa nella matrice restituita.
Se viene specificata un'istanza Attribute di ed è la proprietà predefinita, viene inclusa nella matrice restituita anche se non è presente alcuna istanza di Attribute nella proprietà .
Se
attributesha un attributo predefinito, il GetProperties metodo corrisponde al caso in cui la proprietà non ha l'attributo applicato.
Se component è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
Si applica a
GetProperties(Object, Boolean)
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce la raccolta di proprietà per un componente specificato utilizzando il descrittore di tipo predefinito.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, bool noCustomTypeDesc);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered.")>]
static member GetProperties : obj * bool -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : obj * bool -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, noCustomTypeDesc As Boolean) As PropertyDescriptorCollection
Parametri
- component
- Object
Componente per cui ottenere le proprietà.
- noCustomTypeDesc
- Boolean
true non considerare le informazioni sulla descrizione del tipo personalizzato; in caso contrario, false.
Valori restituiti
Oggetto PropertyDescriptorCollection con le proprietà per un componente specificato.
- Attributi
Eccezioni
component è un oggetto remoto tra processi.
Commenti
Le proprietà per il component parametro possono differire dalle proprietà di una classe, perché il sito può aggiungere o rimuovere proprietà se il component parametro è sito.
Se component è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- ICustomTypeDescriptor
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
Si applica a
GetProperties(Type, Attribute[])
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce la raccolta di proprietà per un tipo specificato di componente utilizzando una matrice di attributi specificata come filtro.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(Type ^ componentType, cli::array <Attribute ^> ^ attributes);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(Type componentType, Attribute[]? attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(Type componentType, Attribute[] attributes);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")>]
static member GetProperties : Type * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : Type * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (componentType As Type, attributes As Attribute()) As PropertyDescriptorCollection
Parametri
Valori restituiti
Oggetto PropertyDescriptorCollection con le proprietà che corrispondono agli attributi specificati per questo tipo di componente.
- Attributi
Esempio
Nell'esempio di codice seguente viene illustrato come implementare il GetProperties metodo . Questo esempio di codice fa parte di un esempio più ampio fornito per la PropertyTab classe .
// Returns the properties of the specified component extended with
// a CategoryAttribute reflecting the name of the type of the property.
[ReflectionPermission(SecurityAction::Demand, Flags=ReflectionPermissionFlag::MemberAccess)]
virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component, array<System::Attribute^>^attributes ) override
{
PropertyDescriptorCollection^ props;
if ( attributes == nullptr )
props = TypeDescriptor::GetProperties( component );
else
props = TypeDescriptor::GetProperties( component, attributes );
array<PropertyDescriptor^>^propArray = gcnew array<PropertyDescriptor^>(props->Count);
for ( int i = 0; i < props->Count; i++ )
{
// Create a new PropertyDescriptor from the old one, with
// a CategoryAttribute matching the name of the type.
array<Attribute^>^temp0 = {gcnew CategoryAttribute( props[ i ]->PropertyType->Name )};
propArray[ i ] = TypeDescriptor::CreateProperty( props[ i ]->ComponentType, props[ i ], temp0 );
}
return gcnew PropertyDescriptorCollection( propArray );
}
virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component ) override
{
return this->GetProperties( component, nullptr );
}
// Returns the properties of the specified component extended with
// a CategoryAttribute reflecting the name of the type of the property.
public override PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes)
{
PropertyDescriptorCollection props = attributes == null ? TypeDescriptor.GetProperties(component) : TypeDescriptor.GetProperties(component, attributes);
PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count];
for (int i = 0; i < props.Count; i++)
{
// Create a new PropertyDescriptor from the old one, with
// a CategoryAttribute matching the name of the type.
propArray[i] = TypeDescriptor.CreateProperty(props[i].ComponentType, props[i], new CategoryAttribute(props[i].PropertyType.Name));
}
return new PropertyDescriptorCollection(propArray);
}
public override PropertyDescriptorCollection GetProperties(object component) => GetProperties(component, null);
Commenti
Chiamare questa versione di questo metodo solo quando non si dispone di un'istanza dell'oggetto .
La attributes matrice di parametri viene usata per filtrare la matrice. Il filtro è definito dalle regole seguenti:
Se una proprietà non dispone di una Attribute classe della stessa classe, la proprietà non viene inclusa nella matrice restituita.
Se l'attributo è un'istanza della Attribute classe , la proprietà deve essere una corrispondenza esatta o non è inclusa nella matrice restituita.
Se viene specificata un'istanza Attribute di ed è la proprietà predefinita, viene inclusa nella matrice restituita anche se non è presente alcuna istanza di Attribute nella proprietà .
Se
attributesha un attributo predefinito, il GetProperties metodo corrisponde al caso in cui la proprietà non ha l'attributo applicato.
Se il componentType parametro è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
Si applica a
GetProperties(Object, Attribute[], Boolean)
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
- Origine:
- TypeDescriptor.cs
Restituisce la raccolta di proprietà per un componente specificato utilizzando una matrice di attributi specificata come filtro e utilizzando un descrittore di tipo personalizzato.
public:
static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, cli::array <Attribute ^> ^ attributes, bool noCustomTypeDesc);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, Attribute[]? attributes, bool noCustomTypeDesc);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes, bool noCustomTypeDesc);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The Type of component cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")>]
static member GetProperties : obj * Attribute[] * bool -> System.ComponentModel.PropertyDescriptorCollection
static member GetProperties : obj * Attribute[] * bool -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, attributes As Attribute(), noCustomTypeDesc As Boolean) As PropertyDescriptorCollection
Parametri
- component
- Object
Componente per cui ottenere le proprietà.
- noCustomTypeDesc
- Boolean
true non considerare le informazioni sulla descrizione del tipo personalizzato; in caso contrario, false.
Valori restituiti
Oggetto PropertyDescriptorCollection con gli eventi che corrispondono agli attributi specificati per il componente specificato.
- Attributi
Eccezioni
component è un oggetto remoto tra processi.
Commenti
Le proprietà di un component oggetto possono differire dalle proprietà di una classe, perché il sito può aggiungere o rimuovere proprietà se component è presente nel sito.
La attributes matrice di parametri viene usata per filtrare la matrice. Il filtro è definito dalle regole seguenti:
Se una proprietà non dispone di una Attribute classe della stessa classe, la proprietà non viene inclusa nella matrice restituita.
Se l'attributo è un'istanza della Attribute classe , la proprietà deve essere una corrispondenza esatta o non è inclusa nella matrice restituita.
Se viene specificata un'istanza Attribute di ed è la proprietà predefinita, viene inclusa nella matrice restituita anche se non è presente alcuna istanza di Attribute nella proprietà .
Se
attributesha un attributo predefinito, il GetProperties metodo corrisponde al caso in cui la proprietà non ha l'attributo applicato.
Se il component parametro è null, viene restituita una raccolta vuota.
L'ordine della raccolta restituita non è garantito che sia identico tra le chiamate, quindi ordinarlo sempre prima dell'utilizzo.
Vedi anche
- PropertyDescriptor
- PropertyDescriptorCollection
- ICustomTypeDescriptor
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents