-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathContainer.cs
More file actions
41 lines (36 loc) · 1.18 KB
/
Container.cs
File metadata and controls
41 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#region Related components
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Collections.Generic;
#endregion
namespace net.vieapps.Components.Utility.Epub
{
class Container
{
private struct RootFile
{
public string File;
public string MediaType;
}
readonly List<RootFile> _rootFiles;
internal Container()
=> this._rootFiles = new List<RootFile>();
internal void AddRootFile(string file, string mediaType)
=> this._rootFiles.Add(new RootFile { File = file, MediaType = mediaType });
internal XElement ToElement()
{
XNamespace ns = "urn:oasis:names:tc:opendocument:xmlns:container";
var element = new XElement(ns + "container", new XAttribute("version", "1.0"));
var filesElement = new XElement(ns + "rootfiles");
foreach (var rootFile in _rootFiles)
{
var fileElement = new XElement(ns + "rootfile", new XAttribute("full-path", rootFile.File), new XAttribute("media-type", rootFile.MediaType));
filesElement.Add(fileElement);
}
element.Add(filesElement);
return element;
}
}
}