DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
ColorList.cs
Go to the documentation of this file.
1 using System.Xml;
2 using System.Xml.Serialization;
3 using DirectOutput.General.Generic;
4 using DirectOutput.Cab.Toys.Layer;
5 
6 namespace DirectOutput.Cab.Color
7 {
8 
12  public class ColorList : NamedItemList<RGBAColorNamed>, IXmlSerializable
13  {
14 
15  #region IXmlSerializable implementation
16 
17 
18 
19 
20  public void WriteXml(XmlWriter writer)
21  {
22 
23  XmlSerializerNamespaces Namespaces = new XmlSerializerNamespaces();
24  Namespaces.Add(string.Empty, string.Empty);
25  foreach (RGBAColorNamed C in this)
26  {
27  XmlSerializer serializer = new XmlSerializer(typeof(RGBAColorNamed));
28  serializer.Serialize(writer, C, Namespaces);
29  }
30  }
31 
32 
37  public void ReadXml(XmlReader reader)
38  {
39  if (reader.IsEmptyElement)
40  {
41  reader.ReadStartElement();
42  return;
43  }
44 
45  reader.Read();
46 
47  while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
48  {
49  if (reader.LocalName == typeof(RGBAColorNamed).Name)
50  {
51 
52  XmlSerializer serializer = new XmlSerializer(typeof(RGBAColorNamed));
53  RGBAColorNamed C = (RGBAColorNamed)serializer.Deserialize(reader);
54  if (!Contains(C.Name))
55  {
56  Add(C);
57  }
58  }
59  else
60  {
61  reader.Skip();
62  }
63  }
64  reader.ReadEndElement();
65  }
66 
67 
72  public System.Xml.Schema.XmlSchema GetSchema() { return (null); }
73  #endregion
74 
75 
76  }
77 }