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

定義

取得值,表示轉換器是否可以將指定來源型別中的物件轉換成轉換器原生型別。Gets a value indicating whether the converter can convert an object of the specified source type to the native type of the converter.

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

ITypeDescriptorContext 物件,可用來取得額外的內容資訊。An ITypeDescriptorContext object that can be used to gain additional context information.

sourceType
Type Type Type Type

Type,表示要轉換的來源型別。A Type that represents the type you wish to convert from.

傳回

如果這個轉換器可以執行轉換,則為 true,否則為 falsetrue if the converter can perform the conversion; otherwise, false.

備註

true如果來源類型為字串, 則這個方法會傳回。This method returns true if the source type is a string. 否則, 這個方法一律false會傳回。Otherwise, this method always returns false.

給繼承者的注意事項

覆寫此方法, 以符合您自己的轉換需求。Override this method to meet your own conversion requirements.

context參數可以用來從正在叫用轉換子的環境中, 解壓縮其他相關資訊。The context parameter can be used to extract additional information about the environment the converter is being invoked from. 這可能是null, 因此您應該一律檢查。It might be null, so you should always check. 此外, context物件的屬性null也可能傳回。Also, properties of the context object might also return null.

適用於

另請參閱