Serialize Color to XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lux

    Serialize Color to XML

    I have :

    enum MyEnum{d1, d2};
    class MyData
    {
    public Color color{}..//get, set
    public MyEnum enum{}..// get,set
    }

    I'm serializing MyData object to xml using XmlSerializer.
    MyData pc = new MyData();

    XmlSerializer xs = new XmlSerializer(t ypeof(MyData));

    TextWriter writer = new StreamWriter("c :\\pra.xml");

    xs.Serialize(wr iter, pc);

    It works but color is not serialized. Why? Color is enum like my MyEnum.

  • Cor Ligthert [MVP]

    #2
    Re: Serialize Color to XML

    Use the method ToArgb and From Argb



    Cor


    "lux" <mark@poczta.on et.plschreef in bericht
    news:g0gt62$76k $1@news.onet.pl ...
    >I have :
    >
    enum MyEnum{d1, d2};
    class MyData
    {
    public Color color{}..//get, set
    public MyEnum enum{}..// get,set
    }
    >
    I'm serializing MyData object to xml using XmlSerializer. MyData pc = new
    MyData();
    >
    XmlSerializer xs = new XmlSerializer(t ypeof(MyData));
    >
    TextWriter writer = new StreamWriter("c :\\pra.xml");
    >
    xs.Serialize(wr iter, pc);
    >
    It works but color is not serialized. Why? Color is enum like my MyEnum.
    >

    Comment

    • Marc Gravell

      #3
      Re: Serialize Color to XML

      Cor's advise re ARGB is correct.

      For the record, color is not an enum; the simple/system colors are
      static properties, not enum values.

      (still missing the "u" though... ;-p)

      Marc

      Comment

      Working...