TypeDescriptor.GetProperties Metódus

Definíció

Egy összetevő vagy típus tulajdonságainak gyűjteményét adja vissza.

Túlterhelések

Name Description
GetProperties(Object)

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza.

GetProperties(Type)

Egy adott típusú összetevő tulajdonságainak gyűjteményét adja vissza.

GetProperties(Object, Attribute[])

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb használatával szűrőként.

GetProperties(Object, Boolean)

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza az alapértelmezett típusleíró használatával.

GetProperties(Type, Attribute[])

Egy adott típusú összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb használatával szűrőként.

GetProperties(Object, Attribute[], Boolean)

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb szűrőként és egyéni típusleíró használatával.

GetProperties(Object)

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza.

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

Paraméterek

component
Object

Egy összetevő, amely lekéri a tulajdonságokat.

Válaszok

A PropertyDescriptorCollection a megadott összetevő tulajdonságaival.

Attribútumok

Kivételek

component egy folyamatközi távoli objektum.

Példák

Az alábbi példakód bemutatja, hogy a GetProperties metódus a vezérlőelemek tulajdonságaihoz való hozzáféréshez használja a metódust. Ez a példakód egy nagyobb, az ComponentDesigner osztályhoz tartozó példa része.

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

Megjegyzések

Az összetevők tulajdonságai eltérhetnek az osztály tulajdonságaitól, mivel a hely akkor adhat hozzá vagy távolíthat el tulajdonságokat, ha az összetevő található.

Ha a component paraméter az null, a függvény egy üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes:

GetProperties(Type)

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott típusú összetevő tulajdonságainak gyűjteményét adja vissza.

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

Paraméterek

componentType
Type

A Type tulajdonságok lekéréséhez használt összetevőt jelöli.

Válaszok

Egy PropertyDescriptorCollection adott típusú összetevő tulajdonságaival.

Attribútumok

Megjegyzések

Ennek a metódusnak a verzióját csak akkor hívja meg, ha nem rendelkezik az objektum egy példányával.

Ha a componentType paraméter az null, a függvény egy üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes:

GetProperties(Object, Attribute[])

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb használatával szűrőként.

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

Paraméterek

component
Object

Egy összetevő, amely lekéri a tulajdonságokat.

attributes
Attribute[]

Szűrőként használni kívánt típusú Attribute tömb.

Válaszok

A PropertyDescriptorCollection tulajdonság, amely megfelel a megadott összetevő megadott attribútumainak.

Attribútumok

Kivételek

component egy folyamatközi távoli objektum.

Példák

Az alábbi példakód bemutatja, hogyan implementálhatja a metódust GetProperties . Ez a példakód egy nagyobb, az PropertyTab osztályhoz tartozó példa része.

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

Megjegyzések

A paraméter tulajdonságai component eltérhetnek az osztály tulajdonságaitól, mivel a hely akkor adhat hozzá vagy távolíthat el tulajdonságokat, ha a component paraméter helyhez van adva.

A attributes paramétertömb a tömb szűrésére szolgál. A szűrést a következő szabályok határozzák meg:

  • Ha egy tulajdonság nem rendelkezik Attribute ugyanahhoz az osztályhoz, a tulajdonság nem szerepel a visszaadott tömbben.

  • Ha az attribútum az Attribute osztály egy példánya, a tulajdonságnak pontos egyezésnek kell lennie, vagy nem szerepel a visszaadott tömbben.

  • Ha egy Attribute példány meg van adva, és ez az alapértelmezett tulajdonság, akkor is szerepel a visszaadott tömbben, ha a tulajdonságnak nincs példánya Attribute .

  • Ha attributes van alapértelmezett attribútuma, akkor a GetProperties metódus akkor egyezik meg, ha a tulajdonság nem alkalmazza az attribútumot.

Ha component igen null, a függvény üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes:

GetProperties(Object, Boolean)

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza az alapértelmezett típusleíró használatával.

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

Paraméterek

component
Object

Egy összetevő, amely lekéri a tulajdonságokat.

noCustomTypeDesc
Boolean

truene vegye figyelembe az egyéni típus leírási adatait; egyéb esetben. false

Válaszok

Egy PropertyDescriptorCollection adott összetevő tulajdonságaival.

Attribútumok

Kivételek

component egy folyamatközi távoli objektum.

Megjegyzések

A paraméter tulajdonságai component eltérhetnek az osztály tulajdonságaitól, mivel a hely akkor adhat hozzá vagy távolíthat el tulajdonságokat, ha a component paraméter helyhez van adva.

Ha component igen null, a függvény üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes:

GetProperties(Type, Attribute[])

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott típusú összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb használatával szűrőként.

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

Paraméterek

componentType
Type

A Type célösszetevő.

attributes
Attribute[]

Szűrőként használni kívánt típusú Attribute tömb.

Válaszok

Egy PropertyDescriptorCollection olyan tulajdonsággal, amely megfelel az ilyen típusú összetevő megadott attribútumainak.

Attribútumok

Példák

Az alábbi példakód bemutatja, hogyan implementálhatja a metódust GetProperties . Ez a példakód egy nagyobb, az PropertyTab osztályhoz tartozó példa része.

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

Megjegyzések

Ennek a metódusnak a verzióját csak akkor hívja meg, ha nem rendelkezik az objektum egy példányával.

A attributes paramétertömb a tömb szűrésére szolgál. A szűrést a következő szabályok határozzák meg:

  • Ha egy tulajdonság nem rendelkezik Attribute ugyanahhoz az osztályhoz, a tulajdonság nem szerepel a visszaadott tömbben.

  • Ha az attribútum az Attribute osztály egy példánya, a tulajdonságnak pontos egyezésnek kell lennie, vagy nem szerepel a visszaadott tömbben.

  • Ha egy Attribute példány meg van adva, és ez az alapértelmezett tulajdonság, akkor is szerepel a visszaadott tömbben, ha a tulajdonságnak nincs példánya Attribute .

  • Ha attributes van alapértelmezett attribútuma, akkor a GetProperties metódus akkor egyezik meg, ha a tulajdonság nem alkalmazza az attribútumot.

Ha a componentType paraméter az null, a függvény egy üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes:

GetProperties(Object, Attribute[], Boolean)

Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs
Forrás:
TypeDescriptor.cs

Egy adott összetevő tulajdonságainak gyűjteményét adja vissza egy megadott attribútumtömb szűrőként és egyéni típusleíró használatával.

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

Paraméterek

component
Object

Egy összetevő, amely lekéri a tulajdonságokat.

attributes
Attribute[]

Szűrőként használni kívánt típusú Attribute tömb.

noCustomTypeDesc
Boolean

truene vegye figyelembe az egyéni típus leírási adatait; egyéb esetben. false

Válaszok

A PropertyDescriptorCollection a megadott összetevő megadott attribútumainak megfelelő eseményekkel.

Attribútumok

Kivételek

component egy folyamatközi távoli objektum.

Megjegyzések

A tulajdonságok eltérhetnek component az osztály tulajdonságaitól, mivel a webhely akkor adhat hozzá vagy távolíthat el tulajdonságokat, ha a component hely található.

A attributes paramétertömb a tömb szűrésére szolgál. A szűrést a következő szabályok határozzák meg:

  • Ha egy tulajdonság nem rendelkezik Attribute ugyanahhoz az osztályhoz, a tulajdonság nem szerepel a visszaadott tömbben.

  • Ha az attribútum az Attribute osztály egy példánya, a tulajdonságnak pontos egyezésnek kell lennie, vagy nem szerepel a visszaadott tömbben.

  • Ha egy Attribute példány meg van adva, és ez az alapértelmezett tulajdonság, akkor is szerepel a visszaadott tömbben, ha a tulajdonságnak nincs példánya Attribute .

  • Ha attributes van alapértelmezett attribútuma, akkor a GetProperties metódus akkor egyezik meg, ha a tulajdonság nem alkalmazza az attribútumot.

Ha a component paraméter az null, a függvény egy üres gyűjteményt ad vissza.

A visszaadott gyűjtemény sorrendje nem garantáltan megegyezik a hívások között, ezért használat előtt mindig rendelje meg.

Lásd még

A következőre érvényes: