4 using System.Xml.Serialization;
5 using DirectOutput.General.Generic;
7 namespace DirectOutput.Cab.Toys
13 public class ToyList : NamedItemList<IToy>, IXmlSerializable
16 #region IXmlSerializable implementation
22 public void WriteXml(XmlWriter writer)
25 XmlSerializerNamespaces Namespaces =
new XmlSerializerNamespaces();
26 Namespaces.Add(
string.Empty,
string.Empty);
27 foreach (
IToy T
in this)
29 XmlSerializer serializer =
new XmlSerializer(T.GetType());
30 serializer.Serialize(writer, T, Namespaces);
40 public void ReadXml(XmlReader reader)
42 if (reader.IsEmptyElement)
44 reader.ReadStartElement();
47 General.TypeList Types =
new General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(
IToy).IsAssignableFrom(p) && !p.IsAbstract));
51 while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
53 Type T = Types[reader.LocalName];
57 XmlSerializer serializer =
new XmlSerializer(T);
58 IToy Toy = (
IToy)serializer.Deserialize(reader);
59 if (!Contains(Toy.
Name))
66 Log.
Warning(
"Toy type {0} not found during deserialization of cabinet data.".Build(reader.LocalName));
72 reader.ReadEndElement();
80 public System.Xml.Schema.XmlSchema
GetSchema() {
return (null); }
89 foreach (
IToy T
in this)
101 foreach (
IToy T
in this)
114 foreach (
IToy T
in this)
124 public void UpdateOutputs()
126 foreach (
IToy T
in this)
130 ((IToyUpdatable)T).UpdateOutputs();