4 using System.Xml.Serialization;
16 #region IXmlSerializable implementation
17 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);
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 if (reader.NodeType == XmlNodeType.Element)
55 Type T = Types[reader.LocalName];
59 XmlSerializer serializer =
new XmlSerializer(T);
60 IToy Toy = (
IToy)serializer.Deserialize(reader);
61 if (!Contains(Toy.
Name))
68 Log.
Warning(
"Toy type {0} not found during deserialization of cabinet data.".Build(reader.LocalName));
79 reader.ReadEndElement();
96 foreach (
IToy T
in this)
108 foreach (
IToy T
in this)
121 foreach (
IToy T
in this)
133 foreach (
IToy T
in this)
137 ((IToyUpdatable)T).UpdateOutputs();
void Finish()
Finishes all toys in the list.
void Reset()
Resets all toys in the list.
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
void Reset()
Must reset the state of the IToy to its default state (off).
void Init(Cabinet Cabinet)
Must initialize the IToy.
void ReadXml(XmlReader reader)
Deserializes the IToy objects in the XmlReader The IToy objects are deserialized using the object nam...
Interface for toys which need a update method which is used to update their outputs.
static void Warning(string Message)
Writes a warning message to the log.
A simple logger used to record important events and exceptions.
void Init(Cabinet Cabinet)
Initializes all IToy objects in the list
System.Xml.Schema.XmlSchema GetSchema()
Method is required by the IXmlSerializable interface
Common interface for all toy implementations. The abstract class ToyBase implements this interface...
void Finish()
Must finish the IToy, do all necessary clean up work and reset the IToy to its default state (off)...
void UpdateOutputs()
Updates the outputs of all toys implementing the IToyUpdatable interface.
new string Name
Gets or sets the Name of the IToy.
A list of uniquely named items which can be referenced by their name.
The namespace DirectOutput.General contains classes for general use.