client/src/Iri.Modernisation.Data/Ldt/IRIFile.cs
changeset 35 43bb1b8ed555
parent 34 4d9ebc6fbbe8
--- a/client/src/Iri.Modernisation.Data/Ldt/IRIFile.cs	Tue Jan 19 09:49:56 2010 +0100
+++ b/client/src/Iri.Modernisation.Data/Ldt/IRIFile.cs	Mon Jan 25 09:30:22 2010 +0100
@@ -8,11 +8,76 @@
 using System.Windows.Media;
 using System.Windows.Media.Animation;
 using System.Windows.Shapes;
-
-namespace Iri.Modernisation.Data.Ldt
+using System.Collections.Generic;
+using System.Xml.Linq;
+namespace Iri.Modernisation.Data.LDTClass
 {
     public class IRIFile
     {
+        public List<IRIMeta> Head { get; set; }
+        public IRIBody Body { get; set; }
+        public IRIFile()
+        {
+            Head = new List<IRIMeta>();
+            Body = new IRIBody();
+        }
+
+        public XDocument XMLFile
+        {
+            get
+            {
+                return new XDocument(XML);
+
+            }
+
+        }
+
+        public override String ToString()
+        {
+            return XML.ToString();
+        }
+
+        public XElement XML
+        {
+            get
+            {
+
+                XElement temp = new XElement("iri");
+
+                XElement Xhead = new XElement("head");
+                foreach (IRIMeta meta in Head)
+                {
+                    Xhead.Add(meta.XML);
+                }
+                temp.Add(Xhead);
+
+                temp.Add(Body.XML);
+
+              
+                return temp;
+            }
+        }
+        public static IRIFile FromXML(XDocument xdoc)
+        {
+            IRIFile returnFile = new IRIFile();
+            foreach (XElement Elem in xdoc.Root.Element("head").Elements())
+            {
+                returnFile.Head.Add(new IRIMeta(Elem));
+            }
+
+            XElement XBody = xdoc.Root.Element("body");
+            foreach (XElement Elem in XBody.Element("ensembles").Elements())
+            {
+                returnFile.Body.Ensembles.Add(new IRIEnsemble(Elem));
+            }
+
+            foreach (XElement Elem in XBody.Element("medias").Elements())
+            {
+                returnFile.Body.Medias.Add(new IRIMedia(Elem));
+            }
+
+            return returnFile;
+        }
 
     }
 }