Edita

Comparteix a través de


KeysConverter.CanConvertFrom(ITypeDescriptorContext, Type) Method

Definition

Returns a value indicating whether this converter can convert an object in the specified source type to the native type of the converter using the specified 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

An ITypeDescriptorContext that provides a format context, which can be used to extract additional information about the environment this converter is being invoked from. This parameter or properties of this parameter can be null.

sourceType
Type

The Type to convert from.

Returns

true if the conversion can be performed; otherwise, false.

Remarks

The CanConvertFrom method is specialized to return true if the sourceType parameter is of type String or Enum array; otherwise, it defers evaluation to the base implementation of this method.

Notes to Inheritors

Override this method to provide your own conversion requirements.

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

Applies to

See also