using System; using System.Collections.Generic; using System.Xml; namespace DMX2 { public class SequenceurMaitre { public class Ligne { public Ligne(){} string nom; TimeSpan duree = TimeSpan.Zero; Dictionary data = new Dictionary(); public string Nom { get { return nom; } set { nom = value; } } public TimeSpan Duree { get { return duree; } set { duree = value; } } public string this [Sequenceur index] { get { string value; if(!data.TryGetValue(index, out value)) return string.Empty; return value; } set { if(value.Length==0) if(data.ContainsKey(index)) data.Remove(index); else data[index] = value; } } public void Save (XmlElement parent) { XmlElement el = parent.OwnerDocument.CreateElement ("Ligne"); parent.AppendChild (el); el.SetAttribute ("nom", nom); el.SetAttribute ("duree", duree.TotalMilliseconds.ToString ()); XmlElement xmlSeq; foreach (var val in data) { el.AppendChild(xmlSeq=parent.OwnerDocument.CreateElement ("data")); xmlSeq.SetAttribute("seq",val.Key.ID.ToString()); xmlSeq.SetAttribute("val",val.Value); } } } List lignes = new List(); public List Lignes { get { return lignes; } } public SequenceurMaitre () { lignes.Add(new Ligne()); } public void Save (XmlElement parent) { XmlElement el = parent.OwnerDocument.CreateElement("SequenceurMaitre"); parent.AppendChild(el); foreach(Ligne l in lignes) l.Save(el); } public static SequenceurMaitre Load (XmlElement doc) { return null; } } }