TypeDescriptor.GetProperties メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コンポーネントまたは型のプロパティのコレクションを返します。
オーバーロード
GetProperties(Object, Attribute[], Boolean) |
指定された属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。 |
GetProperties(Object, Boolean) |
既定の型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。 |
GetProperties(Type, Attribute[]) |
指定された属性配列をフィルターとして使用して、指定されたコンポーネント型のプロパティのコレクションを返します。 |
GetProperties(Type) |
指定された型のコンポーネントのプロパティ コレクションを返します。 |
GetProperties(Object) |
指定されたコンポーネントのプロパティのコレクションを返します。 |
GetProperties(Object, Attribute[]) |
指定された属性配列をフィルターとして使用して、指定されたコンポーネントのプロパティのコレクションを返します。 |
GetProperties(Object, Attribute[], Boolean)
指定された属性配列をフィルターとして使用し、カスタム型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。
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
プロパティを取得する対象のコンポーネント。
- noCustomTypeDesc
- Boolean
カスタム型の説明情報を検討しない場合は true
。それ以外の場合は false
。
戻り値
指定のコンポーネントの指定した属性と一致するイベントを持つ PropertyDescriptorCollection。
例外
component
はプロセス間リモート オブジェクトです。
注釈
component
サイトがサイト化されている場合、サイトでプロパティを追加または削除できるため、a のプロパティはクラスのcomponent
プロパティとは異なる場合があります。
attributes
パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティ Attribute に同じクラスがない場合、プロパティは返された配列に含まれません。
属性がクラスのインスタンスである Attribute 場合、プロパティは完全に一致する必要があります。または、返される配列には含まれません。
インスタンスが Attribute 指定され、それが既定のプロパティである場合は、プロパティ内にインスタンス Attribute がない場合でも、返される配列に含まれます。
既定の属性がある場合
attributes
、プロパティに GetProperties 属性が適用されていない場合、メソッドは大文字と小文字が一致します。
パラメーターが指定されている component
場合は null
、空のコレクションが返されます。
返されるコレクションの順序は呼び出し間で同一であるとは限らないので、使用する前に常に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- ICustomTypeDescriptor
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Object, Boolean)
既定の型記述子を使用して、指定されたコンポーネントのプロパティのコレクションを返します。
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
プロパティとは異なる場合があります。
ある場合 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);
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
パラメーター
戻り値
この型のコンポーネントの指定された属性に一致するプロパティを伴う 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);
}
' Returns the properties of the specified component extended with
' a CategoryAttribute reflecting the name of the type of the property.
Public Overloads Overrides Function GetProperties(ByVal component As Object, ByVal attributes() As System.Attribute) As System.ComponentModel.PropertyDescriptorCollection
Dim props As PropertyDescriptorCollection
If attributes Is Nothing Then
props = TypeDescriptor.GetProperties(component)
Else
props = TypeDescriptor.GetProperties(component, attributes)
End If
Dim propArray(props.Count - 1) As PropertyDescriptor
Dim i As Integer
For i = 0 To props.Count - 1
' 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))
Next i
Return New PropertyDescriptorCollection(propArray)
End Function
Public Overloads Overrides Function GetProperties(ByVal component As Object) As System.ComponentModel.PropertyDescriptorCollection
Return Me.GetProperties(component, Nothing)
End Function
注釈
このバージョンのこのメソッドは、オブジェクトのインスタンスがない場合にのみ呼び出します。
attributes
パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティ Attribute に同じクラスがない場合、プロパティは返された配列に含まれません。
属性がクラスのインスタンスである Attribute 場合、プロパティは完全に一致する必要があります。または、返される配列には含まれません。
インスタンスが Attribute 指定され、それが既定のプロパティである場合は、プロパティ内にインスタンス Attribute がない場合でも、返される配列に含まれます。
既定の属性がある場合
attributes
、プロパティに GetProperties 属性が適用されていない場合、メソッドは大文字と小文字が一致します。
パラメーターが指定されている componentType
場合は null
、空のコレクションが返されます。
返されるコレクションの順序は呼び出し間で同一であるとは限らないので、使用する前に常に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Type)
指定された型のコンポーネントのプロパティ コレクションを返します。
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
パラメーター
戻り値
指定された型のコンポーネントのプロパティを格納する PropertyDescriptorCollection。
注釈
このバージョンのこのメソッドは、オブジェクトのインスタンスがない場合にのみ呼び出します。
パラメーターが指定されている componentType
場合は null
、空のコレクションが返されます。
返されるコレクションの順序は呼び出し間で同一であるとは限らないので、使用する前に常に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
適用対象
GetProperties(Object)
指定されたコンポーネントのプロパティのコレクションを返します。
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
、空のコレクションが返されます。
返されるコレクションの順序は呼び出し間で同一であるとは限らないので、使用する前に常に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents
- 方法: デザイン時サービスにアクセスする
適用対象
GetProperties(Object, Attribute[])
指定された属性配列をフィルターとして使用して、指定されたコンポーネントのプロパティのコレクションを返します。
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
プロパティを取得する対象のコンポーネント。
戻り値
指定のコンポーネントの指定した属性と一致するプロパティを持つ 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);
}
' Returns the properties of the specified component extended with
' a CategoryAttribute reflecting the name of the type of the property.
Public Overloads Overrides Function GetProperties(ByVal component As Object, ByVal attributes() As System.Attribute) As System.ComponentModel.PropertyDescriptorCollection
Dim props As PropertyDescriptorCollection
If attributes Is Nothing Then
props = TypeDescriptor.GetProperties(component)
Else
props = TypeDescriptor.GetProperties(component, attributes)
End If
Dim propArray(props.Count - 1) As PropertyDescriptor
Dim i As Integer
For i = 0 To props.Count - 1
' 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))
Next i
Return New PropertyDescriptorCollection(propArray)
End Function
Public Overloads Overrides Function GetProperties(ByVal component As Object) As System.ComponentModel.PropertyDescriptorCollection
Return Me.GetProperties(component, Nothing)
End Function
注釈
パラメーターがサイト化されている component
場合、サイトでプロパティを追加または削除できるため、パラメーターのプロパティはクラスの component
プロパティとは異なる場合があります。
attributes
パラメーター配列は、配列をフィルター処理するために使用されます。 フィルター処理は、次の規則によって定義されます。
プロパティ Attribute に同じクラスがない場合、プロパティは返された配列に含まれません。
属性がクラスのインスタンスである Attribute 場合、プロパティは完全に一致する必要があります。または、返される配列には含まれません。
インスタンスが Attribute 指定され、それが既定のプロパティである場合は、プロパティ内にインスタンス Attribute がない場合でも、返される配列に含まれます。
既定の属性がある場合
attributes
、プロパティに GetProperties 属性が適用されていない場合、メソッドは大文字と小文字が一致します。
ある場合 component
は null
、空のコレクションが返されます。
返されるコレクションの順序は呼び出し間で同一であるとは限らないので、使用する前に常に並べ替えます。
こちらもご覧ください
- PropertyDescriptor
- PropertyDescriptorCollection
- GetProperties
- GetDefaultProperty
- CreateProperty
- GetAttributes
- GetEvents