TypeDescriptor.GetProperties Metoda

Definice

Vrátí kolekci vlastností komponenty nebo typu.

Přetížení

Name Description
GetProperties(Object)

Vrátí kolekci vlastností pro zadanou komponentu.

GetProperties(Type)

Vrátí kolekci vlastností pro zadaný typ komponenty.

GetProperties(Object, Attribute[])

Vrátí kolekci vlastností pro zadanou komponentu pomocí zadaného pole atributů jako filtru.

GetProperties(Object, Boolean)

Vrátí kolekci vlastností pro zadanou komponentu pomocí výchozího popisovače typu.

GetProperties(Type, Attribute[])

Vrátí kolekci vlastností pro zadaný typ komponenty pomocí zadaného pole atributů jako filtru.

GetProperties(Object, Attribute[], Boolean)

Vrátí kolekci vlastností pro zadanou komponentu pomocí zadaného pole atributů jako filtru a pomocí vlastního popisovače typu.

GetProperties(Object)

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadanou komponentu.

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

Parametry

component
Object

Komponenta pro získání vlastností.

Návraty

A PropertyDescriptorCollection s vlastnostmi pro zadanou komponentu.

Atributy

Výjimky

component je objekt vzdáleného procesu.

Příklady

Následující příklad kódu ukazuje použití GetProperties metody pro přístup k vlastnostem ovládacího prvku. Tento příklad kódu je součástí většího příkladu uvedeného pro třídu ComponentDesigner.

// 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

Poznámky

Vlastnosti komponenty se můžou lišit od vlastností třídy, protože web může přidat nebo odebrat vlastnosti, pokud je komponenta v lokalitě.

Pokud je componentparametr null , vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro

GetProperties(Type)

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadaný typ komponenty.

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

Parametry

componentType
Type

A Type , který představuje komponentu pro získání vlastností.

Návraty

A PropertyDescriptorCollection s vlastnostmi pro zadaný typ komponenty.

Atributy

Poznámky

Tuto verzi této metody zavolejte pouze v případě, že nemáte instanci objektu.

Pokud je componentTypeparametr null , vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro

GetProperties(Object, Attribute[])

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadanou komponentu pomocí zadaného pole atributů jako filtru.

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

Parametry

component
Object

Komponenta pro získání vlastností.

attributes
Attribute[]

Pole typu Attribute , které se má použít jako filtr.

Návraty

A PropertyDescriptorCollection s vlastnostmi, které odpovídají zadaným atributům pro zadanou komponentu.

Atributy

Výjimky

component je objekt vzdáleného procesu.

Příklady

Následující příklad kódu ukazuje, jak implementovat metodu GetProperties . Tento příklad kódu je součástí většího příkladu uvedeného pro třídu PropertyTab.

// 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);

Poznámky

Vlastnosti parametru component se mohou lišit od vlastností třídy, protože web může přidat nebo odebrat vlastnosti, pokud component je parametr sited.

Pole attributes parametrů slouží k filtrování pole. Filtrování je definováno následujícími pravidly:

  • Pokud vlastnost nemá stejnou Attribute třídu, vlastnost není zahrnuta do vráceného pole.

  • Pokud je atribut instance Attribute třídy, vlastnost musí být přesná shoda nebo není zahrnuta do vráceného pole.

  • Attribute Pokud je zadána instance a je to výchozí vlastnost, je zahrnuta do vrácené pole, i když neexistuje žádná instance Attribute v vlastnosti.

  • Pokud attributes má výchozí atribut, metoda odpovídá případu, GetProperties pokud vlastnost nemá použitý atribut.

Pokud component ano null, vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro

GetProperties(Object, Boolean)

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadanou komponentu pomocí výchozího popisovače typu.

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

Parametry

component
Object

Komponenta pro získání vlastností.

noCustomTypeDesc
Boolean

truenebere v úvahu informace o popisu vlastního typu; v opačném případě . false

Návraty

A PropertyDescriptorCollection s vlastnostmi pro zadanou komponentu.

Atributy

Výjimky

component je objekt vzdáleného procesu.

Poznámky

Vlastnosti parametru component se mohou lišit od vlastností třídy, protože web může přidat nebo odebrat vlastnosti, pokud component je parametr sited.

Pokud component ano null, vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro

GetProperties(Type, Attribute[])

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadaný typ komponenty pomocí zadaného pole atributů jako filtru.

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

Parametry

componentType
Type

Cílová komponenta Type .

attributes
Attribute[]

Pole typu Attribute , které se má použít jako filtr.

Návraty

A PropertyDescriptorCollection s vlastnostmi, které odpovídají zadaným atributům pro tento typ komponenty.

Atributy

Příklady

Následující příklad kódu ukazuje, jak implementovat metodu GetProperties . Tento příklad kódu je součástí většího příkladu uvedeného pro třídu PropertyTab.

// 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);

Poznámky

Tuto verzi této metody zavolejte pouze v případě, že nemáte instanci objektu.

Pole attributes parametrů slouží k filtrování pole. Filtrování je definováno následujícími pravidly:

  • Pokud vlastnost nemá stejnou Attribute třídu, vlastnost není zahrnuta do vráceného pole.

  • Pokud je atribut instance Attribute třídy, vlastnost musí být přesná shoda nebo není zahrnuta do vráceného pole.

  • Attribute Pokud je zadána instance a je to výchozí vlastnost, je zahrnuta do vrácené pole, i když neexistuje žádná instance Attribute v vlastnosti.

  • Pokud attributes má výchozí atribut, metoda odpovídá případu, GetProperties pokud vlastnost nemá použitý atribut.

Pokud je componentTypeparametr null , vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro

GetProperties(Object, Attribute[], Boolean)

Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs
Zdroj:
TypeDescriptor.cs

Vrátí kolekci vlastností pro zadanou komponentu pomocí zadaného pole atributů jako filtru a pomocí vlastního popisovače typu.

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

Parametry

component
Object

Komponenta pro získání vlastností.

attributes
Attribute[]

Pole typu Attribute , které se má použít jako filtr.

noCustomTypeDesc
Boolean

truenebere v úvahu informace o popisu vlastního typu; v opačném případě . false

Návraty

A PropertyDescriptorCollection s událostmi, které odpovídají zadaným atributům pro zadanou komponentu.

Atributy

Výjimky

component je objekt vzdáleného procesu.

Poznámky

Vlastnosti třídy component se mohou lišit od vlastností třídy, protože web může přidávat nebo odebírat vlastnosti, pokud component je sited.

Pole attributes parametrů slouží k filtrování pole. Filtrování je definováno následujícími pravidly:

  • Pokud vlastnost nemá stejnou Attribute třídu, vlastnost není zahrnuta do vráceného pole.

  • Pokud je atribut instance Attribute třídy, vlastnost musí být přesná shoda nebo není zahrnuta do vráceného pole.

  • Attribute Pokud je zadána instance a je to výchozí vlastnost, je zahrnuta do vrácené pole, i když neexistuje žádná instance Attribute v vlastnosti.

  • Pokud attributes má výchozí atribut, metoda odpovídá případu, GetProperties pokud vlastnost nemá použitý atribut.

Pokud je componentparametr null , vrátí se prázdná kolekce.

Pořadí vrácených kolekcí není zaručeno, že je mezi voláními stejné, takže je vždy před použitím objednávejte.

Viz také

Platí pro