DateTimeSerializationSection.DateTimeSerializationMode 枚举

定义

确定 DateTime 对象的 XML 序列化格式。Determines XML serialization format of DateTime objects.

此 API 支持产品基础结构,不能在代码中直接使用。

public: enum class DateTimeSerializationSection::DateTimeSerializationMode
public enum DateTimeSerializationSection.DateTimeSerializationMode
type DateTimeSerializationSection.DateTimeSerializationMode = 
Public Enum DateTimeSerializationSection.DateTimeSerializationMode
继承
DateTimeSerializationSection.DateTimeSerializationMode

字段

Default 0

Roundtrip 相同。Same as Roundtrip.

Local 2

序列化程序将所有 DateTime 对象格式设置为本地时间。The serializer formats all DateTime objects as local time. 这是为了版本 1.0 和 1.1 的兼容性。This is for version 1.0 and 1.1 compatibility.

Roundtrip 1

序列化程序检查各个 DateTime 实例,确定序列化格式:UTC、本地或未指定。The serializer examines individual DateTime instances to determine the serialization format: UTC, local, or unspecified.

注解

此枚举仅供序列化基础结构使用, 不用于公共用途。This enumeration is used by the serialization infrastructure only, and is not intended for public use. 若要实际设置序列化模式, 请创建应用程序配置文件, 并 <将> datetimeserialization&gt 元素设置为适当的设置。To actually set the serialization mode, create an application configuration file, and set the <dateTimeSerialization> Element to an appropriate setting. 有关配置文件的详细信息,请参阅配置文件架构For more information about configuration files, see Configuration File Schema.

在版本1.0 和1.1 的 .NET Framework 以及版本2.0 和更高版本中, 如果此属性设置为Local, DateTime则始终将对象格式化为本地时间。In versions 1.0 and 1.1 of .NET Framework, as well as in versions 2.0 and later when this property is set to Local, DateTime objects are always formatted as the local time. 即,序列化的数据中总是包含本地时区信息。That is, local time zone information is always included with the serialized data. 将此属性设置为 Local 可确保与较早版本的 .NET Framework 相兼容。Set this property to Local to ensure compatibility with older versions of the .NET Framework.

在 .NET Framework 版本2.0 及更高版本中, 将对设置为Roundtrip DateTime "对象" 的属性进行检查, 以确定它们是在本地、UTC 还是未指定的时区中, 并以这种方式对其进行序列化丢失.In versions 2.0 and later of the .NET Framework, with this property set to RoundtripDateTime objects are examined to determine whether they are in the local, UTC or an unspecified time zone, and are serialized in such a way that this information is preserved. 这是默认行为, 建议用于不与 framework 的较旧版本通信的所有新应用程序。This is the default behavior and is recommended for all new applications that do not communicate with older versions of the framework.

适用于

另请参阅