Пример #1
0
		private string WritePolicySetVersion(IPolicySetVersionCache version, bool runtime)
		{
			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes");

			XmlElement root = xmlDoc.CreateElement("PolicySet");
            XmlAttribute id = xmlDoc.CreateAttribute("id");
            id.Value = Convert.ToString((version as LocalPolicySetVersionCache).ID, CultureInfo.InvariantCulture);
            XmlAttribute rootname = xmlDoc.CreateAttribute("name");
			rootname.Value = version.GetName("en");
            root.Attributes.Append(id);
            root.Attributes.Append(rootname);

            XmlElement content = xmlDoc.CreateElement("Content");
		    if (!runtime)
		    {
		        content.InnerXml = version.Content;
		    }

		    // create the catalogues
			XmlElement cats = xmlDoc.CreateElement("Catalogues");

		    if (!runtime)
		    {
		        //add the master cat
		        if (version.MasterCatalogue != null)
		            cats.AppendChild(WriteCatalogueInfo(xmlDoc, version.MasterCatalogue, true));

		        //add the ref catalogues
		        foreach (IPolicyCatalogueCache cat in version.ReferenceCatalogues)
		            cats.AppendChild(WriteCatalogueInfo(xmlDoc, cat, false));
		    }

		    // create the compiled policy sets
			XmlElement compiledsets = xmlDoc.CreateElement("CompiledPolicySets");

		    foreach (ICompiledPolicySetCache cps in version.CompiledPolicySets)
		    {
                if (cps.Target == "Client" && ((cps.Channel == "SMTP") || (cps.Channel == "ActiveContent")))
		            compiledsets.AppendChild(WriteCompiledPolicySetInfo(xmlDoc, cps));
		    }

		    root.AppendChild(content);
			root.AppendChild(cats);
			root.AppendChild(compiledsets);

			xmlDoc.AppendChild(root);
			return xmlDoc.OuterXml;
		}