Прочетете на английски Редактиране

Споделяне чрез


TypeDescriptionProvider.GetTypeDescriptor Method

Definition

Gets a custom type descriptor for the given type or object.

Overloads

GetTypeDescriptor(Object)

Gets a custom type descriptor for the given object.

GetTypeDescriptor(Type)

Gets a custom type descriptor for the given type.

GetTypeDescriptor(Type, Object)

Gets a custom type descriptor for the given type and object.

GetTypeDescriptor(Object)

Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs

Gets a custom type descriptor for the given object.

C#
public System.ComponentModel.ICustomTypeDescriptor? GetTypeDescriptor(object instance);
C#
public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(object instance);

Parameters

instance
Object

An instance of the type. Can be null if no instance was passed to the TypeDescriptor.

Returns

An ICustomTypeDescriptor that can provide metadata for the type.

Exceptions

instance is null.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10
.NET Framework 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

GetTypeDescriptor(Type)

Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs

Gets a custom type descriptor for the given type.

C#
public System.ComponentModel.ICustomTypeDescriptor? GetTypeDescriptor(Type objectType);
C#
public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(Type objectType);

Parameters

objectType
Type

The type of object for which to retrieve the type descriptor.

Returns

An ICustomTypeDescriptor that can provide metadata for the type.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10
.NET Framework 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

GetTypeDescriptor(Type, Object)

Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs
Source:
TypeDescriptionProvider.cs

Gets a custom type descriptor for the given type and object.

C#
public virtual System.ComponentModel.ICustomTypeDescriptor? GetTypeDescriptor(Type objectType, object? instance);
C#
public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance);

Parameters

objectType
Type

The type of object for which to retrieve the type descriptor.

instance
Object

An instance of the type. Can be null if no instance was passed to the TypeDescriptor.

Returns

An ICustomTypeDescriptor that can provide metadata for the type.

Remarks

This method is prototyped as virtual and, by default, returns an empty descriptor if no parent provider was passed. If a parent provider was passed, this method will invoke the parent provider's GetTypeDescriptor method.

Notes to Inheritors

The GetTypeDescriptor(Type, Object) method should return a custom type descriptor for the object. If the method does not provide type information for the object, it should return null.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.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, 10
.NET Framework 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