Beispiel #1
0
        /// <summary>
        /// Parses WebDav_MultiResponse from 'DAV:multistatus' element.
        /// </summary>
        /// <param name="stream">DAV:multistatus response stream.</param>
        /// <returns>Returns DAV multistatus.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> is null reference.</exception>
        /// <exception cref="ParseException">Is raised when there are any parsing error.</exception>
        internal static WebDav_MultiStatus Parse(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            XmlDocument response = new XmlDocument();

            response.Load(stream);

            // Invalid response.
            if (!string.Equals(response.ChildNodes[1].NamespaceURI + response.ChildNodes[1].LocalName, "DAV:multistatus", Helpers.GetDefaultIgnoreCaseComparison()))
            {
                throw new ParseException("Invalid DAV:multistatus value.");
            }

            WebDav_MultiStatus retVal = new WebDav_MultiStatus();

            // Parse responses.
            foreach (XmlNode responseNode in response.ChildNodes[1].ChildNodes)
            {
                retVal.Responses.Add(WebDav_Response.Parse(responseNode));
            }

            return(retVal);
        }
        /// <summary>
        /// Parses WebDav_MultiResponse from 'DAV:multistatus' element.
        /// </summary>
        /// <param name="stream">DAV:multistatus response stream.</param>
        /// <returns>Returns DAV multistatus.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> is null reference.</exception>
        /// <exception cref="ParseException">Is raised when there are any parsing error.</exception>
        internal static WebDav_MultiStatus Parse(Stream stream)
        {
            if(stream == null){
                throw new ArgumentNullException("stream");
            }            
           
            XmlDocument response = new XmlDocument();
            response.Load(stream);
                      
            // Invalid response.
            if(!string.Equals(response.ChildNodes[1].NamespaceURI + response.ChildNodes[1].LocalName,"DAV:multistatus",StringComparison.InvariantCultureIgnoreCase)){
                throw new ParseException("Invalid DAV:multistatus value.");
            }
       
            WebDav_MultiStatus retVal = new WebDav_MultiStatus();

            // Parse responses.
            foreach(XmlNode responseNode in response.ChildNodes[1].ChildNodes){
                retVal.Responses.Add(WebDav_Response.Parse(responseNode));
            }

            return retVal;
        }