TypeDescriptor.GetProperties メソッド

定義

コンポーネントまたは型のプロパティのコレクションを返します。

オーバーロード

GetProperties(Object, Attribute[], Boolean)

指定された属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。

GetProperties(Object, Boolean)

既定の型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。

GetProperties(Type, Attribute[])

指定された属性配列をフィルターとして使用して、指定されたコンポーネント型のプロパティのコレクションを返します。

GetProperties(Type)

指定された型のコンポーネントのプロパティ コレクションを返します。

GetProperties(Object)

指定されたコンポーネントのプロパティのコレクションを返します。

GetProperties(Object, Attribute[])

指定された属性配列をフィルターとして使用して、指定されたコンポーネントのプロパティのコレクションを返します。

GetProperties(Object, Attribute[], Boolean)

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

指定された属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, cli::array <Attribute ^> ^ attributes, bool noCustomTypeDesc);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component, Attribute[] attributes, bool noCustomTypeDesc);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component, Attribute[]? attributes, bool noCustomTypeDesc);
static member GetProperties : obj * Attribute[] * bool -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, attributes As Attribute(), noCustomTypeDesc As Boolean) As PropertyDescriptorCollection

パラメーター

component
Object

プロパティを取得する対象のコンポーネント。

attributes
Attribute[]

フィルターとして使用する型 Attribute の配列。

noCustomTypeDesc
Boolean

カスタム型の説明情報を検討しない場合は true。それ以外の場合は false

戻り値

指定のコンポーネントの指定した属性と一致するイベントを持つ PropertyDescriptorCollection

例外

component はプロセス間リモート オブジェクトです。

注釈

のプロパティ component は、 がサイト化されている場合にプロパティを追加または削除できるため、クラスの component プロパティとは異なる場合があります。

attributesパラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。

  • プロパティに同じクラスの が Attribute 含まれていない場合、プロパティは返される配列に含まれません。

  • 属性が クラスの Attribute インスタンスである場合、 プロパティは完全に一致している必要があります。または、返される配列に含まれません。

  • インスタンスが Attribute 指定され、それが既定のプロパティである場合、 プロパティに のインスタンス Attribute がない場合でも、返される配列に含まれます。

  • に既定の属性がある場合 attributesGetProperties プロパティに 属性が適用されていない場合、メソッドは 大文字と小文字が一致します。

パラメーターが の component 場合は null、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象

GetProperties(Object, Boolean)

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

既定の型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, bool noCustomTypeDesc);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component, bool noCustomTypeDesc);
static member GetProperties : obj * bool -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, noCustomTypeDesc As Boolean) As PropertyDescriptorCollection

パラメーター

component
Object

プロパティを取得する対象のコンポーネント。

noCustomTypeDesc
Boolean

カスタム型の説明情報を検討しない場合は true。それ以外の場合は false

戻り値

指定されたコンポーネントのプロパティを持つ PropertyDescriptorCollection

例外

component はプロセス間リモート オブジェクトです。

注釈

パラメーターの component プロパティは、パラメーターがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスの component プロパティとは異なる場合があります。

nullの場合componentは、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象

GetProperties(Type, Attribute[])

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

指定された属性配列をフィルターとして使用して、指定されたコンポーネント型のプロパティのコレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(Type ^ componentType, cli::array <Attribute ^> ^ attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (Type componentType, Attribute[] attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (Type componentType, Attribute[]? attributes);
static member GetProperties : Type * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (componentType As Type, attributes As Attribute()) As PropertyDescriptorCollection

パラメーター

componentType
Type

対象コンポーネントの Type

attributes
Attribute[]

フィルターとして使用する型 Attribute の配列。

戻り値

この型のコンポーネントの指定された属性に一致するプロパティを伴う PropertyDescriptorCollection

次のコード例は、 メソッドを実装する方法を GetProperties 示しています。 このコード例は、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 System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes)
{
    PropertyDescriptorCollection props;
    if( attributes == null )
        props = TypeDescriptor.GetProperties(component);    
    else
        props = 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 System.ComponentModel.PropertyDescriptorCollection GetProperties(object component)
{                     
    return this.GetProperties(component, null);
}

注釈

オブジェクトのインスタンスがない場合にのみ、このメソッドのこのバージョンを呼び出します。

attributesパラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。

  • プロパティに同じクラスの が Attribute 含まれていない場合、プロパティは返される配列に含まれません。

  • 属性が クラスの Attribute インスタンスである場合、 プロパティは完全に一致している必要があります。または、返される配列に含まれません。

  • インスタンスが Attribute 指定され、それが既定のプロパティである場合、 プロパティに のインスタンス Attribute がない場合でも、返される配列に含まれます。

  • に既定の属性がある場合 attributesGetProperties プロパティに 属性が適用されていない場合、メソッドは 大文字と小文字が一致します。

パラメーターが の componentType 場合は null、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象

GetProperties(Type)

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

指定された型のコンポーネントのプロパティ コレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(Type ^ componentType);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (Type componentType);
static member GetProperties : Type -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (componentType As Type) As PropertyDescriptorCollection

パラメーター

componentType
Type

プロパティを取得する対象のコンポーネントを表す Type

戻り値

指定された型のコンポーネントのプロパティを格納する PropertyDescriptorCollection

注釈

オブジェクトのインスタンスがない場合にのみ、このメソッドのこのバージョンを呼び出します。

パラメーターが の componentType 場合は null、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象

GetProperties(Object)

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

指定されたコンポーネントのプロパティのコレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component);
static member GetProperties : obj -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object) As PropertyDescriptorCollection

パラメーター

component
Object

プロパティを取得する対象のコンポーネント。

戻り値

指定されたコンポーネントのプロパティを持つ PropertyDescriptorCollection

例外

component はプロセス間リモート オブジェクトです。

次のコード例では、 メソッドを使用してコントロールの GetProperties プロパティにアクセスする方法を示します。 このコード例は、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
    {
        return (Color)ShadowProperties["BackColor"];
    }
    set
    {
        if (this.changeService != null)
        {
            PropertyDescriptor backColorDesc =
                TypeDescriptor.GetProperties(this.Control)["BackColor"];

            this.changeService.OnComponentChanging(
                this.Control,
                backColorDesc);

            this.ShadowProperties["BackColor"] = value;

            this.changeService.OnComponentChanged(
                this.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

注釈

コンポーネントのプロパティは、コンポーネントがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスのプロパティとは異なる場合があります。

パラメーターが の component 場合は null、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象

GetProperties(Object, Attribute[])

ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs
ソース:
TypeDescriptor.cs

指定された属性配列をフィルターとして使用して、指定されたコンポーネントのプロパティのコレクションを返します。

public:
 static System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(System::Object ^ component, cli::array <Attribute ^> ^ attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component, Attribute[] attributes);
public static System.ComponentModel.PropertyDescriptorCollection GetProperties (object component, Attribute[]? attributes);
static member GetProperties : obj * Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
Public Shared Function GetProperties (component As Object, attributes As Attribute()) As PropertyDescriptorCollection

パラメーター

component
Object

プロパティを取得する対象のコンポーネント。

attributes
Attribute[]

フィルターとして使用する型 Attribute の配列。

戻り値

指定のコンポーネントの指定した属性と一致するプロパティを持つ PropertyDescriptorCollection

例外

component はプロセス間リモート オブジェクトです。

次のコード例は、 メソッドを実装する方法を GetProperties 示しています。 このコード例は、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 System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes)
{
    PropertyDescriptorCollection props;
    if( attributes == null )
        props = TypeDescriptor.GetProperties(component);    
    else
        props = 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 System.ComponentModel.PropertyDescriptorCollection GetProperties(object component)
{                     
    return this.GetProperties(component, null);
}

注釈

パラメーターの component プロパティは、パラメーターがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスの component プロパティとは異なる場合があります。

attributesパラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。

  • プロパティに同じクラスの が Attribute 含まれていない場合、プロパティは返される配列に含まれません。

  • 属性が クラスの Attribute インスタンスである場合、 プロパティは完全に一致している必要があります。または、返される配列に含まれません。

  • インスタンスが Attribute 指定され、それが既定のプロパティである場合、 プロパティに のインスタンス Attribute がない場合でも、返される配列に含まれます。

  • に既定の属性がある場合 attributesGetProperties プロパティに 属性が適用されていない場合、メソッドは 大文字と小文字が一致します。

nullの場合componentは、空のコレクションが返されます。

返されるコレクションの順序は、呼び出し間で同一であることが保証されないため、常に使用する前に並べ替えます。

こちらもご覧ください

適用対象