TimeSpanSecondsOrInfiniteConverter.ConvertFrom(ITypeDescriptorContext, CultureInfo, Object) 方法

定义

String 转换为 TimeSpanConverts 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

参数

ctx
ITypeDescriptorContext

用于类型转换的 ITypeDescriptorContext 对象。The ITypeDescriptorContext object used for type conversions.

ci
CultureInfo

转换期间使用的 CultureInfo 对象。The CultureInfo object used during conversion.

data
Object

要转换的 String 对象。The String object to convert.

返回

Object

如果 data 参数是 MaxValue“infinite”,则为 String;否则为以秒表示 data 参数的 TimeSpanThe MaxValue, if the data parameter is the String "infinite"; otherwise, the TimeSpan representing the data parameter in seconds.

示例

请参阅和类中的代码 InfiniteTimeSpanConverter 示例 TimeSpanMinutesConverterRefer to the code examples in the InfiniteTimeSpanConverter and TimeSpanMinutesConverter classes.

注解

ConvertFrom从配置文件读取时,系统使用将值转换为 String TimeSpan ,或将 String "无限大" 转换为 MaxValueThe system uses ConvertFrom when reading from a configuration file to convert a String value to TimeSpan, or the String "infinite" to MaxValue.

适用于