DateTimeValueSerializer Class

Definition

String 的实例与 DateTime 的实例进行来回转换。Converts instances of String to and from instances of DateTime.

public ref class DateTimeValueSerializer : System::Windows::Markup::ValueSerializer
public class DateTimeValueSerializer : System.Windows.Markup.ValueSerializer
type DateTimeValueSerializer = class
    inherit ValueSerializer
Public Class DateTimeValueSerializer
Inherits ValueSerializer
Inheritance
DateTimeValueSerializer

Remarks

在类型转换需要附加状态的情况下,将使用 ValueSerializer 而不是 TypeConverterValueSerializer is used rather than TypeConverter for cases where type conversion requires additional state. DateTimeValueSerializer 未使用 ValueSerializerAttribute的类型。DateTimeValueSerializer is not attributed to a type with ValueSerializerAttribute. 这是因为 DateTime 在 mscorlib.dll 中,而 mscorlib 不能依赖于它不会自行定义的属性类。This is because DateTime is in mscorlib, and mscorlib cannot take dependencies on attribute classes that it does not define itself. 相反,DateTimeValueSerializer 的用法在 xaml 处理 .NET Framework XAML 服务行为中采用特殊大小写方式。Instead, usage of DateTimeValueSerializer is special-cased into XAML processor behavior in .NET Framework XAML Services behavior.

在 .NET Framework 的以前版本中,此类存在于 WPF 特定的程序集 WindowsBase 中。In previous versions of the .NET Framework, this class existed in the WPF-specific assembly WindowsBase. .NET Framework 4.NET Framework 4中,DateTimeValueSerializer 在 system.exception 程序集中。In .NET Framework 4.NET Framework 4, DateTimeValueSerializer is in the System.Xaml assembly. 请参阅从 WPF 迁移到System.exception 的类型。See Types Migrated from WPF to System.Xaml.

Constructors

DateTimeValueSerializer()

初始化 DateTimeValueSerializer 类的新实例。Initializes a new instance of the DateTimeValueSerializer class.

Methods

CanConvertFromString(String, IValueSerializerContext)

确定指定的 String 是否可以转换为 DateTime 的实例。Determines if the specified String can be convert to an instance of DateTime.

CanConvertToString(Object, IValueSerializerContext)

确定能否将指定的对象转换为 StringDetermines if the specified object can be converted to a String.

ConvertFromString(String, IValueSerializerContext)

String 转换为 DateTimeConverts a String into a DateTime.

ConvertToString(Object, IValueSerializerContext)

DateTime 的实例转换为 StringConverts an instance of DateTime to a String.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetConvertFromException(Object)

返回当转换无法执行时所引发的异常。Returns an exception to throw when a conversion cannot be performed.

(Inherited from ValueSerializer)
GetConvertToException(Object, Type)

返回当转换无法执行时所引发的异常。Returns an exception to throw when a conversion cannot be performed.

(Inherited from ValueSerializer)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
TypeReferences(Object, IValueSerializerContext)

获取 ValueSerializer 引用的类型的枚举。Gets an enumeration of the types referenced by the ValueSerializer.

(Inherited from ValueSerializer)

Applies to

See also