TimeSpanMinutesConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) TimeSpanMinutesConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) TimeSpanMinutesConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) TimeSpanMinutesConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) Method

Definizione

Converte String in TimeSpan.Converts a String to a TimeSpan.

public:
 override System::Object ^ ConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ ctx, System::Globalization::CultureInfo ^ ci, System::Object ^ data);
public override object ConvertFrom (System.ComponentModel.ITypeDescriptorContext ctx, System.Globalization.CultureInfo ci, object data);
override this.ConvertFrom : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj -> obj
Public Overrides Function ConvertFrom (ctx As ITypeDescriptorContext, ci As CultureInfo, data As Object) As Object

Parametri

ctx
ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext

Oggetto ITypeDescriptorContext utilizzato per le conversioni dei tipi.The ITypeDescriptorContext object used for type conversions.

ci
CultureInfo CultureInfo CultureInfo CultureInfo

Oggetto CultureInfo utilizzato durante la conversione.The CultureInfo object used during conversion.

data
Object Object Object Object

Oggetto String da convertire.The String object to convert.

Restituisce

Oggetto TimeSpan che rappresenta il parametro data in minuti.The TimeSpan representing the data parameter in minutes.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato ConvertFrom come personalizzare il metodo.The following code example shows how to customize the ConvertFrom method.

public override object ConvertFrom(
    ITypeDescriptorContext ctx, CultureInfo ci, object data)
{

    long min = long.Parse((string)data,
        CultureInfo.InvariantCulture);

    return TimeSpan.FromMinutes((double)min);
}
Public Overrides Function ConvertFrom( _
ByVal ctx As ITypeDescriptorContext, _
ByVal ci As CultureInfo, ByVal data As Object) As Object

    Dim min As Long = _
    Long.Parse(CStr(data), CultureInfo.InvariantCulture)

    Return TimeSpan.FromMinutes(System.Convert.ToDouble(min))

End Function 'ConvertFrom

Commenti

Il sistema usa il ConvertFrom metodo durante la lettura da un file di configurazione per String convertire un TimeSpanvalore in.The system uses the ConvertFrom method when reading from a configuration file to convert a String value to TimeSpan.

Si applica a