DateTimeValueSerializer 类

定义

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
继承
DateTimeValueSerializer

注解

ValueSerializer在类型转换需要TypeConverter附加状态的情况下, 使用而不是。ValueSerializer 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 中是, 而 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 4DateTimeValueSerializer , 为 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.

构造函数

DateTimeValueSerializer()

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

方法

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.

(继承自 Object)
GetConvertFromException(Object)

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

(继承自 ValueSerializer)
GetConvertToException(Object, Type)

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

(继承自 ValueSerializer)
GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 Object)
MemberwiseClone()

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

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TypeReferences(Object, IValueSerializerContext)

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

(继承自 ValueSerializer)

适用于

另请参阅