4 using System.Xml.Serialization;
5 using DirectOutput.General.Generic;
7 namespace DirectOutput.Cab.Out
13 public class OutputList : NamedItemList<IOutput>, IXmlSerializable
16 #region IXmlSerializable implementation
22 public void WriteXml(XmlWriter writer)
25 XmlSerializerNamespaces Namespaces =
new XmlSerializerNamespaces();
26 Namespaces.Add(
string.Empty,
string.Empty);
29 XmlSerializer serializer =
new XmlSerializer(E.GetType());
30 serializer.Serialize(writer, E, 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(
IOutput).IsAssignableFrom(p) && !p.IsAbstract));
51 while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
53 Type T = Types[reader.LocalName];
56 XmlSerializer serializer =
new XmlSerializer(T);
58 if (!Contains(O.
Name))
69 reader.ReadEndElement();
79 public System.Xml.Schema.XmlSchema
GetSchema() {
return (null); }
85 #region Event handling
87 void OutputList_BeforeClear(
object sender, EventArgs e)
95 void OutputList_AfterRemove(
object sender, RemoveEventArgs<IOutput> e)
97 e.Item.ValueChanged -=
new Output.ValueChangedEventHandler(Item_ValueChanged);
100 void OutputList_AfterInsert(
object sender, InsertEventArgs<IOutput> e)
102 e.Item.ValueChanged +=
new Output.ValueChangedEventHandler(Item_ValueChanged);
105 void OutputList_AfterSet(
object sender, SetEventArgs<IOutput> e)
107 e.OldItem.ValueChanged -=
new Output.ValueChangedEventHandler(Item_ValueChanged);
108 e.NewItem.ValueChanged +=
new Output.ValueChangedEventHandler(Item_ValueChanged);
111 void Item_ValueChanged(
object sender, OutputEventArgs e)
113 OnOutputValueChanged(e.Output);
118 #region ValueChanged Event
127 if (OutputValueChanged != null)
143 public delegate
void OutputValueChangedEventHandler(
object sender,
OutputEventArgs e);
155 this.AfterInsert +=
new EventHandler<InsertEventArgs<IOutput>>(OutputList_AfterInsert);
156 this.AfterRemove +=
new EventHandler<RemoveEventArgs<IOutput>>(OutputList_AfterRemove);
157 this.AfterSet +=
new EventHandler<SetEventArgs<IOutput>>(OutputList_AfterSet);
158 this.BeforeClear +=
new EventHandler<EventArgs>(OutputList_BeforeClear);