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.

public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor (object instance);
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 9 and other versions
Product Versions
.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 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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 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.

public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor (Type objectType);
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 9 and other versions
Product Versions
.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 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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 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.

public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor (Type objectType, object instance);
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 9 and other versions
Product Versions
.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 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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0, 2.1