OpacityConverter.CanConvertFrom(ITypeDescriptorContext, Type) OpacityConverter.CanConvertFrom(ITypeDescriptorContext, Type) OpacityConverter.CanConvertFrom(ITypeDescriptorContext, Type) OpacityConverter.CanConvertFrom(ITypeDescriptorContext, Type) Method

定义

返回一个值,该值指示此转换器是否可将指定源类型的对象转换为使用指定上下文的转换器的本机类型。Returns a value indicating whether this converter can convert an object of the specified source type to the native type of the converter that uses the specified context.

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

参数

context
ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext

提供类型转换器上下文信息的 ITypeDescriptorContextA ITypeDescriptorContext that provides information about the context of a type converter.

sourceType
Type Type Type Type

表示要转换的类型的 TypeThe Type that represents the type you want to convert from.

返回

如果该转换器能够执行转换,则为 true;否则为 falsetrue if this converter can perform the conversion; otherwise, false.

注解

sourceTypeString为。The sourceType is expected to be a String.

继承者说明

重写该方法以提供您自己的转换需求。Override this method to provide your own conversion requirements.

可以使用context参数来提取有关从中调用此转换器的环境的其他信息。You can use the context parameter to extract additional information about the environment this converter is being invoked from. 参数可以为null, 因此应始终验证内容。The parameter may be null, so you should always verify the contents. 此外, 上的ITypeDescriptorContext属性还可能返回。 nullAlso, properties on the ITypeDescriptorContext may also return null.

适用于

另请参阅