Click here to Skip to main content
15,922,427 members
Home / Discussions / C#
   

C#

 
GeneralRe: One Line Pin
Christian Graus4-Jan-04 12:58
protectorChristian Graus4-Jan-04 12:58 
GeneralRe: One Line Pin
eggie54-Jan-04 13:01
eggie54-Jan-04 13:01 
GeneralRe: One Line Pin
Christian Graus4-Jan-04 13:06
protectorChristian Graus4-Jan-04 13:06 
GeneralRe: One Line Pin
eggie54-Jan-04 13:42
eggie54-Jan-04 13:42 
GeneralRe: One Line Pin
Heath Stewart4-Jan-04 18:51
protectorHeath Stewart4-Jan-04 18:51 
GeneralRe: One Line Pin
eggie55-Jan-04 11:51
eggie55-Jan-04 11:51 
QuestionDateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Chris Richner4-Jan-04 11:56
Chris Richner4-Jan-04 11:56 
AnswerRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Heath Stewart4-Jan-04 18:46
protectorHeath Stewart4-Jan-04 18:46 
XML serialization doesn't make use of a TypeConverter. It is hard-coded to format the intrinsic types and several common types like a DateTime. You could instead implement the IXmlSerializable interface. Though it's undocumented, it's pretty easy to figure out. Otherwise, you could create your own XmlSerializationReader and XmlSerializationWriter, but both are also undocumented and very complex. I'd recommend implementing IXmlSerializable on your class that contains the DateTime you want to format differently.

Also, you could always have a public property that returns and accepts a string in the format you want. You could use XmlIgnoreAttribute on the actual DateTime proeprty while using the value from the string property:
[XmlRoot("example")]
public class Example
{
  // ...
  [XmlIgnore]
  public DateTime DT
  {
    get { return this.dt; }
    set { this.dt = value; }
  }

  [XmlElement("dt")]
  public string DTFormat
  {
    get { return this.dt.ToString("r"); }
    set { this.dt = DateTime.Parse(value); }
  }
}
Note, using the format specifier "r" in DateTime.ToString says that it outputs a date-time in RFC 1123, but this RFC is not found the the format looks the same. Use a custom format if I am wrong.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Chris Richner4-Jan-04 20:11
Chris Richner4-Jan-04 20:11 
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Heath Stewart5-Jan-04 4:03
protectorHeath Stewart5-Jan-04 4:03 
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Chris Richner5-Jan-04 5:55
Chris Richner5-Jan-04 5:55 
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Heath Stewart5-Jan-04 6:00
protectorHeath Stewart5-Jan-04 6:00 
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Chris Richner5-Jan-04 8:52
Chris Richner5-Jan-04 8:52 
GeneralRe: DateTime Property, custom TypeConverter for XmlSerialisation ? Pin
Heath Stewart5-Jan-04 9:53
protectorHeath Stewart5-Jan-04 9:53 
GeneralList of ODBC DSN's Pin
webdudeIA4-Jan-04 10:53
webdudeIA4-Jan-04 10:53 
GeneralRe: List of ODBC DSN's Pin
Nick Parker4-Jan-04 11:25
protectorNick Parker4-Jan-04 11:25 
GeneralRe: List of ODBC DSN's Pin
webdudeIA4-Jan-04 13:18
webdudeIA4-Jan-04 13:18 
GeneralRe: List of ODBC DSN's Pin
Nick Parker4-Jan-04 16:52
protectorNick Parker4-Jan-04 16:52 
GeneralRe: List of ODBC DSN's Pin
cjengler5-Jan-04 2:25
cjengler5-Jan-04 2:25 
GeneralBig Problem with multicasting. Pin
HAHAHA_NEXT4-Jan-04 10:48
HAHAHA_NEXT4-Jan-04 10:48 
GeneralRe: Big Problem with multicasting. Pin
leppie4-Jan-04 11:12
leppie4-Jan-04 11:12 
GeneralRe: Big Problem with multicasting. Pin
HAHAHA_NEXT4-Jan-04 16:13
HAHAHA_NEXT4-Jan-04 16:13 
GeneralRe: Big Problem with multicasting. Pin
Heath Stewart4-Jan-04 18:22
protectorHeath Stewart4-Jan-04 18:22 
GeneralRe: Big Problem with multicasting. Pin
leppie5-Jan-04 6:24
leppie5-Jan-04 6:24 
GeneralRe: Big Problem with multicasting. Pin
HAHAHA_NEXT5-Jan-04 7:10
HAHAHA_NEXT5-Jan-04 7:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.