internal override void WriteTo(XmlTextWriter writer)
{
XmlDocument doc = new XmlDocument();
XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
manager.AddNamespace("prop", NSPackageProperties);
manager.AddNamespace("dc", NSDc);
manager.AddNamespace("dcterms", NSDcTerms);
manager.AddNamespace("xsi", NSXsi);
// Create XML declaration
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", null));
// Create root node with required namespace declarations
XmlNode coreProperties = doc.AppendChild(doc.CreateNode(XmlNodeType.Element, "coreProperties", NSPackageProperties));
coreProperties.Attributes.Append(doc.CreateAttribute("xmlns:dc")).Value = NSDc;
coreProperties.Attributes.Append(doc.CreateAttribute("xmlns:dcterms")).Value = NSDcTerms;
coreProperties.Attributes.Append(doc.CreateAttribute("xmlns:xsi")).Value = NSXsi;
// Create the children
if (Category != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "category", NSPackageProperties)).InnerXml = Category;
if (ContentStatus != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "contentStatus", NSPackageProperties)).InnerXml = ContentStatus;
if (ContentType != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "contentType", NSPackageProperties)).InnerXml = ContentType;
if (Created.HasValue)
{
XmlAttribute att = doc.CreateAttribute("xsi", "type", NSXsi);
att.Value = "dcterms:W3CDTF";
XmlNode created = coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dcterms", "created", NSDcTerms));
created.Attributes.Append(att);
created.InnerXml = Created.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") + "Z";
}
if (Creator != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "creator", NSDc)).InnerXml = Creator;
if (Description != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "description", NSDc)).InnerXml = Description;
if (Identifier != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "identifier", NSDc)).InnerXml = Identifier;
if (Keywords != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "keywords", NSPackageProperties)).InnerXml = Keywords;
if (Language != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "language", NSDc)).InnerXml = Language;
if (LastModifiedBy != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "lastModifiedBy", NSPackageProperties)).InnerXml = LastModifiedBy;
if (LastPrinted.HasValue)
{
XmlNode lastPrinted = coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "lastPrinted", NSPackageProperties));
lastPrinted.InnerXml = LastPrinted.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") + "Z";
}
if (Revision != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "revision", NSPackageProperties)).InnerXml = Revision;
if (Subject != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "subject", NSDc)).InnerXml = Subject;
if (Title != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dc", "title", NSDc)).InnerXml = Title;
if (Version != null)
coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "version", NSPackageProperties)).InnerXml = Version;
if (Modified.HasValue)
{
XmlAttribute att = doc.CreateAttribute("xsi", "type", NSXsi);
att.Value = "dcterms:W3CDTF";
XmlNode modified = coreProperties.AppendChild(doc.CreateNode(XmlNodeType.Element, "dcterms", "modified", NSDcTerms));
modified.Attributes.Append(att);
modified.InnerXml = Modified.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss") + "Z";
}
doc.WriteContentTo(writer);
}