Επεξεργασία

Κοινή χρήση μέσω


TypeDescriptor.AddProvider Method

Definition

Adds a type description provider to the list of providers for this type descriptor.

Overloads

AddProvider(TypeDescriptionProvider, Object)

Adds a type description provider for a single instance of a component.

AddProvider(TypeDescriptionProvider, Type)

Adds a type description provider for a component class.

AddProvider(TypeDescriptionProvider, Object)

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

Adds a type description provider for a single instance of a component.

public:
 static void AddProvider(System::ComponentModel::TypeDescriptionProvider ^ provider, System::Object ^ instance);
public static void AddProvider (System.ComponentModel.TypeDescriptionProvider provider, object instance);
static member AddProvider : System.ComponentModel.TypeDescriptionProvider * obj -> unit
Public Shared Sub AddProvider (provider As TypeDescriptionProvider, instance As Object)

Parameters

instance
Object

An instance of the target component.

Exceptions

One or both of the parameters are null.

Remarks

The AddProvider(TypeDescriptionProvider, Object) method adds a type description provider that supplies type information for a single instance of a component. If a provider is added by this method, the provider's CreateInstance method will not be called because the instance already exists.

This method does not maintain a hard reference to the component, so it does not prevent the component from finalizing.

It is possible to add multiple type description providers for the same type or object. If this occurs, the first type description provider encountered that provides type information will be used exclusively. Since type information providers are stored in a stack, the last provider added will be the first one queried. This behavior enables the AddProvider(TypeDescriptionProvider, Object) and RemoveProvider methods to be used to push and pop type description providers as required for particular scenarios.

If successful, this method calls the Refresh(Object) method on the instance parameter.

Note

The two versions of this method produce results with different scopes. The AddProvider method that takes an Object parameter affects only that single instance of the component specified. In contrast, the other overload, which takes a Type parameter, affects all instances of the component described by that type.

Use the AddProviderTransparent(TypeDescriptionProvider, Object) method if you need to call from partially trusted code.

See also

Applies to

AddProvider(TypeDescriptionProvider, Type)

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

Adds a type description provider for a component class.

public:
 static void AddProvider(System::ComponentModel::TypeDescriptionProvider ^ provider, Type ^ type);
public static void AddProvider (System.ComponentModel.TypeDescriptionProvider provider, Type type);
static member AddProvider : System.ComponentModel.TypeDescriptionProvider * Type -> unit
Public Shared Sub AddProvider (provider As TypeDescriptionProvider, type As Type)

Parameters

type
Type

The Type of the target component.

Exceptions

One or both of the parameters are null.

Remarks

The AddProvider(TypeDescriptionProvider, Type) method adds a type description provider that supplies type information for the specified class, derived classes, and all instances of these types.

Note

The type parameter can be any type, including an interface. For example, to provide custom type and instance information for all components, you would specify typeof(IComponent). Passing typeof(object) will call the provider to supply type information for all types.

This method does not maintain a hard reference to any object, so it does not prevent objects from finalizing.

It is possible to add multiple type description providers for the same type or object. If this occurs, the first type description provider encountered that provides type information will be used exclusively. Because type information providers are stored in a stack, the last provider added will be the first one queried. This behavior enables the AddProvider(TypeDescriptionProvider, Type) and RemoveProvider methods to be used to push and pop type description providers as required for particular scenarios.

If successful, this method calls the Refresh(Type) method on the type parameter.

Note

The two versions of this method produce results with different scopes. The AddProvider method that takes an Object parameter affects only that single instance of the component specified. In contrast, the other overload, which takes a Type parameter, affects all instances of the component described by that type.

Use the AddProviderTransparent(TypeDescriptionProvider, Type) method if you need to call from partially trusted code.

See also

Applies to