ConfigurationConverterBase.CanConvertFrom メソッド

定義

変換できるかどうかを確認します。

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

パラメーター

ctx
ITypeDescriptorContext

型変換に使用される ITypeDescriptorContext オブジェクト。

type
Type

変換対象の Type

戻り値

変換できる場合は true。それ以外の場合は false

次のコード例は、 メソッドをオーバーライド CanConvertFrom してカスタム TimeSpan コンバーター型を作成する方法を示しています。 また、この例では、カスタム セクションでこの型を使用する方法を示します。

public override bool CanConvertFrom(
    ITypeDescriptorContext ctx, Type type)
{
    return (type == typeof(string));
}
Public Overrides Function CanConvertFrom( _
ByVal ctx As ITypeDescriptorContext, _
ByVal type As Type) As Boolean
    Return (type.ToString() = GetType(String).ToString())

End Function 'CanConvertFrom

注釈

メソッドは CanConvertFrom 、厳密に型指定されたプロパティに対して変換を実行して、構成ファイルで使用される値文字列を取得できるかどうかを決定します。

適用対象