/// <summary> /// Builds the <see cref="XmlDocument" /> containing the response body /// </summary> /// <param name="context">The <see cref="IHttpListenerContext" /></param> /// <param name="propname">The boolean defining the Propfind propname request</param> /// <param name="requestUri"></param> /// <param name="requestedProperties"></param> /// <param name="webDavStoreItems"></param> /// <param name="lockSystem"></param> /// <param name="store"></param> /// <returns> /// The <see cref="XmlDocument" /> containing the response body /// </returns> private string ResponseDocument(IHttpListenerContext context, bool propname, Uri requestUri, List<WebDavProperty> requestedProperties, List<IWebDavStoreItem> webDavStoreItems, IWebDavStoreItemLock lockSystem, IWebDavStore store) { // Create the basic response XmlDocument XmlDocument responseDoc = new XmlDocument(); const string responseXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:multistatus xmlns:D=\"DAV:\" xmlns:Office=\"urn:schemas-microsoft-com:office:office\" xmlns:Repl=\"http://schemas.microsoft.com/repl/\" xmlns:Z=\"urn:schemas-microsoft-com:\"></D:multistatus>"; responseDoc.LoadXml(responseXml); // Generate the manager XmlNamespaceManager manager = new XmlNamespaceManager(responseDoc.NameTable); manager.AddNamespace("D", "DAV:"); manager.AddNamespace("Office", "schemas-microsoft-com:office:office"); manager.AddNamespace("Repl", "http://schemas.microsoft.com/repl/"); manager.AddNamespace("Z", "urn:schemas-microsoft-com:"); List<string> xmlFragments = new List<string>(); int count = 0; foreach (IWebDavStoreItem webDavStoreItem in webDavStoreItems) { string frag; if (count == 0) { frag = CreateFragment(true, responseDoc, webDavStoreItem, context, propname, requestUri, requestedProperties, lockSystem); } else { WindowsIdentity userIdentity = (WindowsIdentity) Thread.GetData(Thread.GetNamedDataSlot(WebDavServer.HttpUser)); string cacheValue = (string) store.GetCacheObject(this, userIdentity.Name, webDavStoreItem.ItemPath); if (cacheValue != null) { xmlFragments.Add(cacheValue); continue; } frag = CreateFragment(false, responseDoc, webDavStoreItem, context, propname, requestUri, requestedProperties, lockSystem); store.AddCacheObject(this, userIdentity.Name, webDavStoreItem.ItemPath, frag); } count++; xmlFragments.Add(frag); } StringBuilder sb = new StringBuilder(5000); sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:multistatus xmlns:D=\"DAV:\" xmlns:Office=\"urn:schemas-microsoft-com:office:office\" xmlns:Repl=\"http://schemas.microsoft.com/repl/\" xmlns:Z=\"urn:schemas-microsoft-com:\">"); foreach (string xmlFragment in xmlFragments) sb.Append(xmlFragment); sb.Append("</D:multistatus>"); string t = sb.ToString(); return t; }