|
34
|
1 |
using System; |
|
|
2 |
using System.Net; |
|
|
3 |
using System.Windows; |
|
|
4 |
using System.Windows.Controls; |
|
|
5 |
using System.Windows.Documents; |
|
|
6 |
using System.Windows.Ink; |
|
|
7 |
using System.Windows.Input; |
|
|
8 |
using System.Windows.Media; |
|
|
9 |
using System.Windows.Media.Animation; |
|
|
10 |
using System.Windows.Shapes; |
|
35
|
11 |
using System.Collections.Generic; |
|
|
12 |
using System.Xml.Linq; |
|
|
13 |
namespace Iri.Modernisation.Data.LDTClass |
|
34
|
14 |
{ |
|
|
15 |
public class IRIFile |
|
|
16 |
{ |
|
35
|
17 |
public List<IRIMeta> Head { get; set; } |
|
|
18 |
public IRIBody Body { get; set; } |
|
|
19 |
public IRIFile() |
|
|
20 |
{ |
|
|
21 |
Head = new List<IRIMeta>(); |
|
|
22 |
Body = new IRIBody(); |
|
|
23 |
} |
|
|
24 |
|
|
|
25 |
public XDocument XMLFile |
|
|
26 |
{ |
|
|
27 |
get |
|
|
28 |
{ |
|
|
29 |
return new XDocument(XML); |
|
|
30 |
|
|
|
31 |
} |
|
|
32 |
|
|
|
33 |
} |
|
|
34 |
|
|
|
35 |
public override String ToString() |
|
|
36 |
{ |
|
|
37 |
return XML.ToString(); |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
public XElement XML |
|
|
41 |
{ |
|
|
42 |
get |
|
|
43 |
{ |
|
|
44 |
|
|
|
45 |
XElement temp = new XElement("iri"); |
|
|
46 |
|
|
|
47 |
XElement Xhead = new XElement("head"); |
|
|
48 |
foreach (IRIMeta meta in Head) |
|
|
49 |
{ |
|
|
50 |
Xhead.Add(meta.XML); |
|
|
51 |
} |
|
|
52 |
temp.Add(Xhead); |
|
|
53 |
|
|
|
54 |
temp.Add(Body.XML); |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
return temp; |
|
|
58 |
} |
|
|
59 |
} |
|
|
60 |
public static IRIFile FromXML(XDocument xdoc) |
|
|
61 |
{ |
|
|
62 |
IRIFile returnFile = new IRIFile(); |
|
|
63 |
foreach (XElement Elem in xdoc.Root.Element("head").Elements()) |
|
|
64 |
{ |
|
|
65 |
returnFile.Head.Add(new IRIMeta(Elem)); |
|
|
66 |
} |
|
|
67 |
|
|
|
68 |
XElement XBody = xdoc.Root.Element("body"); |
|
|
69 |
foreach (XElement Elem in XBody.Element("ensembles").Elements()) |
|
|
70 |
{ |
|
|
71 |
returnFile.Body.Ensembles.Add(new IRIEnsemble(Elem)); |
|
|
72 |
} |
|
|
73 |
|
|
|
74 |
foreach (XElement Elem in XBody.Element("medias").Elements()) |
|
|
75 |
{ |
|
|
76 |
returnFile.Body.Medias.Add(new IRIMedia(Elem)); |
|
|
77 |
} |
|
|
78 |
|
|
|
79 |
return returnFile; |
|
|
80 |
} |
|
34
|
81 |
|
|
|
82 |
} |
|
|
83 |
} |