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))
71 reader.ReadEndElement();
79 public System.Xml.Schema.XmlSchema
GetSchema() {
return (null); }
88 foreach (
IToy T
in this)
100 foreach (
IToy T
in this)
113 foreach (
IToy T
in this)
123 public void UpdateOutputs()
125 foreach (
IToy T
in this)
129 ((IToyUpdatable)T).UpdateOutputs();