Rediger

Del via


SelectionRangeConverter.CanConvertFrom(ITypeDescriptorContext, Type) Method

Definition

Determines if this converter can convert an object of the specified source type to the native type of the converter by querying the supplied type descriptor context.

public:
 override bool CanConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ context, Type ^ sourceType);
public override bool CanConvertFrom (System.ComponentModel.ITypeDescriptorContext context, Type sourceType);
public override bool CanConvertFrom (System.ComponentModel.ITypeDescriptorContext? context, Type sourceType);
override this.CanConvertFrom : System.ComponentModel.ITypeDescriptorContext * Type -> bool
Public Overrides Function CanConvertFrom (context As ITypeDescriptorContext, sourceType As Type) As Boolean

Parameters

context
ITypeDescriptorContext

A ITypeDescriptorContext that provides a format context.

sourceType
Type

The source Type to be converted.

Returns

true if the converter can perform the specified conversion; otherwise, false.

Remarks

The SelectionRangeConverter class is specialized to convert between the types String and SelectionRange. As a result, the CanConvertFrom method returns true if the sourceType parameter is of type String. Otherwise, it defers the call to the base implementation of this method, TypeConverter.CanConvertFrom(ITypeDescriptorContext, Type).

Notes to Inheritors

Override this method to provide your own conversion requirements.

The context parameter can be used to extract additional information about the environment this converter is being invoked from. The parameter may be null, so you should always verify the information. Also, properties on the context object may also return null.

Applies to

See also