TypeConverter.GetProperties 方法

定義

傳回由值參數所指定的陣列型別的屬性集合。

多載

GetProperties(Object)

傳回由值參數所指定的陣列型別的屬性集合。

GetProperties(ITypeDescriptorContext, Object)

會使用指定的內容,傳回由值參數所指定之陣列型別的屬性集合。

GetProperties(ITypeDescriptorContext, Object, Attribute[])

使用指定的內容和屬性 (attribute),傳回由該值參數所指定之陣列類型的屬性 (property) 集合。

GetProperties(Object)

來源:
TypeConverter.cs
來源:
TypeConverter.cs
來源:
TypeConverter.cs

傳回由值參數所指定的陣列型別的屬性集合。

C#
public System.ComponentModel.PropertyDescriptorCollection GetProperties (object value);
C#
public System.ComponentModel.PropertyDescriptorCollection? GetProperties (object value);

參數

value
Object

Object,指定要取得屬性之陣列的型別。

傳回

具有為這個資料類型所公開之屬性的 PropertyDescriptorCollection,或者,如果沒有屬性則為 null

備註

在這個類別中實作時,這個方法永遠傳回 null

根據預設,類型不會傳回屬性。 這個方法的簡單實作可以呼叫 GetProperties 正確的數據類型。

適用於

.NET 9 和其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetProperties(ITypeDescriptorContext, Object)

來源:
TypeConverter.cs
來源:
TypeConverter.cs
來源:
TypeConverter.cs

會使用指定的內容,傳回由值參數所指定之陣列型別的屬性集合。

C#
public System.ComponentModel.PropertyDescriptorCollection GetProperties (System.ComponentModel.ITypeDescriptorContext context, object value);
C#
public System.ComponentModel.PropertyDescriptorCollection? GetProperties (System.ComponentModel.ITypeDescriptorContext? context, object value);

參數

context
ITypeDescriptorContext

提供格式內容的 ITypeDescriptorContext

value
Object

Object,指定要取得屬性之陣列的型別。

傳回

具有為這個資料類型所公開之屬性的 PropertyDescriptorCollection,或者,如果沒有屬性則為 null

備註

context 參數可以用於擷取環境的其他資訊,而這個轉換子就是從該環境叫用的。 此參數可以是 null,因此請一律檢查它。 甚至,內容物件上的屬性可能會傳回 null

在這個類別中實作時,這個方法永遠傳回 null

根據預設,類型不會傳回屬性。 這個方法的簡單實作可以呼叫 GetProperties 正確的數據類型。

另請參閱

適用於

.NET 9 和其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetProperties(ITypeDescriptorContext, Object, Attribute[])

來源:
TypeConverter.cs
來源:
TypeConverter.cs
來源:
TypeConverter.cs

使用指定的內容和屬性 (attribute),傳回由該值參數所指定之陣列類型的屬性 (property) 集合。

C#
public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties (System.ComponentModel.ITypeDescriptorContext context, object value, Attribute[] attributes);
C#
public virtual System.ComponentModel.PropertyDescriptorCollection? GetProperties (System.ComponentModel.ITypeDescriptorContext? context, object value, Attribute[]? attributes);

參數

context
ITypeDescriptorContext

提供格式內容的 ITypeDescriptorContext

value
Object

Object,指定要取得屬性之陣列的型別。

attributes
Attribute[]

Attribute 類型陣列,可當做篩選條件使用。

傳回

具有為這個資料類型所公開之屬性的 PropertyDescriptorCollection,或者,如果沒有屬性則為 null

備註

在這個類別中實作時,這個方法永遠傳回 null

給繼承者的注意事項

如果您想要轉換的類型支援屬性,請覆寫這個方法。

context 參數可以用於擷取環境的其他資訊,而這個轉換子就是從該環境叫用的。 此參數可以是 null,因此請一律檢查它。 甚至,內容物件上的屬性可能會傳回 null

屬性陣列是用來篩選陣列。 屬性可以混合 TypeAttribute 物件。 篩選是由下列規則所定義:

  • Type會被視為通配符;它會比對在其屬性集中具有 Type 的屬性。

  • 如果屬性沒有 Attribute 相同類別的 ,則屬性不會包含在傳回的陣列中。

  • 如果屬性是的 Attribute實例,則屬性必須是完全相符的,否則不會包含在傳回的陣列中。

  • Attribute如果指定實例且它是預設屬性,則即使 屬性中沒有的Attribute實例,它也會包含在傳回的數位中。

另請參閱

適用於

.NET 9 和其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1