TypeDescriptor.GetProperties メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コンポーネントまたは型のプロパティのコレクションを返します。
オーバーロード
| 名前 | 説明 |
|---|---|
| GetProperties(Object) |
指定したコンポーネントのプロパティのコレクションを返します。 |
| GetProperties(Type) |
指定した種類のコンポーネントのプロパティのコレクションを返します。 |
| GetProperties(Object, Attribute[]) |
指定した属性の配列をフィルターとして使用して、指定したコンポーネントのプロパティのコレクションを返します。 |
| GetProperties(Object, Boolean) |
既定の型記述子を使用して、指定したコンポーネントのプロパティのコレクションを返します。 |
| GetProperties(Type, Attribute[]) |
指定した属性配列をフィルターとして使用して、指定した種類のコンポーネントのプロパティのコレクションを返します。 |
| GetProperties(Object, Attribute[], Boolean) |
指定した属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定したコンポーネントのプロパティのコレクションを返します。 |
GetProperties(Object)
指定したコンポーネントのプロパティのコレクションを返します。
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
パラメーター
- 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 => (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
注釈
コンポーネントのプロパティは、コンポーネントがサイト化されている場合にプロパティを追加または削除できるため、クラスのプロパティとは異なる場合があります。
component パラメーターがnullの場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Type)
指定した種類のコンポーネントのプロパティのコレクションを返します。
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
パラメーター
返品
指定した種類のコンポーネントのプロパティを持つ PropertyDescriptorCollection 。
- 属性
注釈
オブジェクトのインスタンスがない場合にのみ、このバージョンのこのメソッドを呼び出します。
componentType パラメーターがnullの場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Object, Attribute[])
指定した属性の配列をフィルターとして使用して、指定したコンポーネントのプロパティのコレクションを返します。
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
パラメーター
- component
- Object
プロパティを取得するコンポーネント。
返品
指定したコンポーネントの指定した属性と一致するプロパティを持つ 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 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);
注釈
component パラメーターのプロパティは、component パラメーターがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスのプロパティとは異なる場合があります。
attributes パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティに同じクラスの Attribute がない場合、プロパティは返される配列に含まれません。
属性が Attribute クラスのインスタンスである場合、プロパティは完全に一致しているか、返された配列に含まれていない必要があります。
Attributeインスタンスが指定され、それが既定のプロパティである場合、プロパティにAttributeのインスタンスがない場合でも、返される配列に含まれます。
attributesに既定の属性がある場合、GetProperties メソッドは、プロパティに属性が適用されていない場合と一致します。
componentがnull場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Object, Boolean)
既定の型記述子を使用して、指定したコンポーネントのプロパティのコレクションを返します。
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
パラメーター
- component
- Object
プロパティを取得するコンポーネント。
- noCustomTypeDesc
- Boolean
true カスタム型の説明情報を考慮しない場合。それ以外の場合は false。
返品
指定したコンポーネントのプロパティを持つ PropertyDescriptorCollection 。
- 属性
例外
component は、プロセス間のリモート オブジェクトです。
注釈
component パラメーターのプロパティは、component パラメーターがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスのプロパティとは異なる場合があります。
componentがnull場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- ICustomTypeDescriptor
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Type, Attribute[])
指定した属性配列をフィルターとして使用して、指定した種類のコンポーネントのプロパティのコレクションを返します。
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
パラメーター
返品
この種類のコンポーネントの指定した属性と一致するプロパティを持つ 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 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);
注釈
オブジェクトのインスタンスがない場合にのみ、このバージョンのこのメソッドを呼び出します。
attributes パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティに同じクラスの Attribute がない場合、プロパティは返される配列に含まれません。
属性が Attribute クラスのインスタンスである場合、プロパティは完全に一致しているか、返された配列に含まれていない必要があります。
Attributeインスタンスが指定され、それが既定のプロパティである場合、プロパティにAttributeのインスタンスがない場合でも、返される配列に含まれます。
attributesに既定の属性がある場合、GetProperties メソッドは、プロパティに属性が適用されていない場合と一致します。
componentType パラメーターがnullの場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Object, Attribute[], Boolean)
指定した属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定したコンポーネントのプロパティのコレクションを返します。
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
パラメーター
- component
- Object
プロパティを取得するコンポーネント。
- noCustomTypeDesc
- Boolean
true カスタム型の説明情報を考慮しない場合。それ以外の場合は false。
返品
指定したコンポーネントの指定した属性と一致するイベントを含む PropertyDescriptorCollection 。
- 属性
例外
component は、プロセス間のリモート オブジェクトです。
注釈
componentのプロパティは、componentがサイト化されている場合にサイトでプロパティを追加または削除できるため、クラスのプロパティとは異なる場合があります。
attributes パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティに同じクラスの Attribute がない場合、プロパティは返される配列に含まれません。
属性が Attribute クラスのインスタンスである場合、プロパティは完全に一致しているか、返された配列に含まれていない必要があります。
Attributeインスタンスが指定され、それが既定のプロパティである場合、プロパティにAttributeのインスタンスがない場合でも、返される配列に含まれます。
attributesに既定の属性がある場合、GetProperties メソッドは、プロパティに属性が適用されていない場合と一致します。
component パラメーターがnullの場合は、空のコレクションが返されます。
返されるコレクションの順序は、呼び出し間で同一であるとは限らないので、必ず使用する前に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- ICustomTypeDescriptor
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents