• <tfoot id='WXdx8'></tfoot>

      1. <i id='WXdx8'><tr id='WXdx8'><dt id='WXdx8'><q id='WXdx8'><span id='WXdx8'><b id='WXdx8'><form id='WXdx8'><ins id='WXdx8'></ins><ul id='WXdx8'></ul><sub id='WXdx8'></sub></form><legend id='WXdx8'></legend><bdo id='WXdx8'><pre id='WXdx8'><center id='WXdx8'></center></pre></bdo></b><th id='WXdx8'></th></span></q></dt></tr></i><div id='WXdx8'><tfoot id='WXdx8'></tfoot><dl id='WXdx8'><fieldset id='WXdx8'></fieldset></dl></div>
      2. <legend id='WXdx8'><style id='WXdx8'><dir id='WXdx8'><q id='WXdx8'></q></dir></style></legend>
        • <bdo id='WXdx8'></bdo><ul id='WXdx8'></ul>

        <small id='WXdx8'></small><noframes id='WXdx8'>

        在没有毫秒和 gmt 的情况下将 DateTime 序列化为时间

        Serializing DateTime to time without milliseconds and gmt(在没有毫秒和 gmt 的情况下将 DateTime 序列化为时间)
          <tbody id='Pw0cV'></tbody>
      3. <i id='Pw0cV'><tr id='Pw0cV'><dt id='Pw0cV'><q id='Pw0cV'><span id='Pw0cV'><b id='Pw0cV'><form id='Pw0cV'><ins id='Pw0cV'></ins><ul id='Pw0cV'></ul><sub id='Pw0cV'></sub></form><legend id='Pw0cV'></legend><bdo id='Pw0cV'><pre id='Pw0cV'><center id='Pw0cV'></center></pre></bdo></b><th id='Pw0cV'></th></span></q></dt></tr></i><div id='Pw0cV'><tfoot id='Pw0cV'></tfoot><dl id='Pw0cV'><fieldset id='Pw0cV'></fieldset></dl></div>

          <bdo id='Pw0cV'></bdo><ul id='Pw0cV'></ul>

            • <legend id='Pw0cV'><style id='Pw0cV'><dir id='Pw0cV'><q id='Pw0cV'></q></dir></style></legend>

              • <small id='Pw0cV'></small><noframes id='Pw0cV'>

                  <tfoot id='Pw0cV'></tfoot>
                1. 本文介绍了在没有毫秒和 gmt 的情况下将 DateTime 序列化为时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 XSD 文件作为输入创建了一个 C# 类文件.我的一个属性如下所示:

                  I have created a C# class file by using a XSD-file as an input. One of my properties look like this:

                   private System.DateTime timeField;
                  
                   [System.Xml.Serialization.XmlElementAttribute(DataType="time")]
                   public System.DateTime Time {
                       get {
                           return this.timeField;
                       }
                       set {
                           this.timeField = value;
                       }
                   }
                  

                  序列化后,文件的内容现在如下所示:

                  When serialized, the contents of the file now looks like this:

                  <Time>14:04:02.1661975+02:00</Time>
                  

                  是否有可能,在属性上使用 XmlAttributes,让它在没有毫秒和 GMT 值的情况下呈现?

                  Is it possible, with XmlAttributes on the property, to have it render without the milliseconds and the GMT-value like this?

                  <Time>14:04:02</Time>
                  

                  这可能吗,还是我需要在类被序列化后组合某种 xsl/xpath-replace-magic?

                  Is this possible, or do i need to hack together some sort of xsl/xpath-replace-magic after the class has been serialized?

                  这不是将对象更改为字符串的解决方案,因为它在应用程序的其余部分中用作 DateTime,并允许我们使用 XmlSerializer.Serialize() 方法从对象创建 xml 表示.

                  It is not a solution to changing the object to String, because it is used like a DateTime in the rest of the application and allows us to create an xml-representation from an object by using the XmlSerializer.Serialize() method.

                  我需要从字段中删除额外信息的原因是接收系统不符合时间数据类型的 w3c 标准.

                  The reason I need to remove the extra info from the field is that the receiving system does not conform to the w3c-standards for the time datatype.

                  推荐答案

                  您可以创建一个字符串属性来执行与 timeField 字段之间的转换,并将序列化属性放在该属性上,而不是其余部分的真实 DateTime 属性应用程序使用.

                  You could create a string property that does the translation to/from your timeField field and put the serialization attribute on that instead the the real DateTime property that the rest of the application uses.

                  这篇关于在没有毫秒和 gmt 的情况下将 DateTime 序列化为时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)
                  Can you omit the parenthesis from attributes with no params?(您可以省略没有参数的属性中的括号吗?)
                  How do I get the XMLSerializer to add namespaces to attributes in nested objects?(如何让 XMLSerializer 将命名空间添加到嵌套对象中的属性?)
                  <legend id='joY7R'><style id='joY7R'><dir id='joY7R'><q id='joY7R'></q></dir></style></legend>
                  <i id='joY7R'><tr id='joY7R'><dt id='joY7R'><q id='joY7R'><span id='joY7R'><b id='joY7R'><form id='joY7R'><ins id='joY7R'></ins><ul id='joY7R'></ul><sub id='joY7R'></sub></form><legend id='joY7R'></legend><bdo id='joY7R'><pre id='joY7R'><center id='joY7R'></center></pre></bdo></b><th id='joY7R'></th></span></q></dt></tr></i><div id='joY7R'><tfoot id='joY7R'></tfoot><dl id='joY7R'><fieldset id='joY7R'></fieldset></dl></div>
                  <tfoot id='joY7R'></tfoot>

                  1. <small id='joY7R'></small><noframes id='joY7R'>

                      <tbody id='joY7R'></tbody>

                    • <bdo id='joY7R'></bdo><ul id='joY7R'></ul>