public XmlElement ToXml(XmlDocument ownerDoc)
{
Contract.Requires<ArgumentNullException>(ownerDoc != null);
const string Ns = XmlNamespaces.ProjectConfigurationNamespace;
XmlElement result = ownerDoc.CreateElement("project", Ns);
if (!string.IsNullOrWhiteSpace(this.Name))
result.SetAttribute("name", this.Name);
if (!string.IsNullOrWhiteSpace(this.SharedCategory))
result.SetAttribute("sharedCategory", this.SharedCategory);
if (!string.IsNullOrWhiteSpace(this.DefaultLocale))
result.SetAttribute("defaultLocale", this.DefaultLocale);
if (!string.IsNullOrWhiteSpace(this.DefaultCategory))
result.SetAttribute("defaultCategory", this.DefaultCategory);
result.SetAttribute("autoInternationalize", this.AutoInternationalize ? "1" : "0");
result.SetAttribute("debugMode", this.IsDebugEnabled ? "1" : "0");
result.AppendChild(this.PathTemplates.ToXml(ownerDoc));
result.AppendChild(this.Routing.ToXml(ownerDoc));
result.AppendChild(this.Linking.ToXml(ownerDoc));
result.AppendChild(this.Environment.ToXml(ownerDoc));
if (this.Modules.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("modules", Ns));
foreach (ModuleConfiguration module in this.Modules.Values)
target.AppendChild(module.ToXml(ownerDoc));
}
if (this.ResourceLibraries.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("libraries", Ns));
foreach (ResourceLibraryInfo library in this.ResourceLibraries.Values)
target.AppendChild(library.ToXml(ownerDoc));
}
if (this.Locales.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("internationalization", Ns));
foreach (LocaleInfo locale in this.Locales.Values)
target.AppendChild(locale.ToXml(ownerDoc));
}
if (this.Categories.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("categories", Ns));
foreach (CategoryInfo category in this.Categories.Values)
target.AppendChild(category.ToXml(ownerDoc));
}
if (this.MetaViews.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("metaViews", Ns));
foreach (MetaViewInfo metaViewInfo in this.MetaViews.Values)
target.AppendChild(metaViewInfo.ToXml(ownerDoc));
}
if (this.ErrorViews.Count != 0)
{
XmlNode target = result.AppendChild(ownerDoc.CreateElement("errorViews", Ns));
foreach (ErrorViewInfo info in this.ErrorViews.Values)
target.AppendChild(info.ToXml(ownerDoc));
}
foreach (XmlElement custom in customElements)
result.AppendChild(ownerDoc.ImportNode(custom, true));
return result;
}