Esempio n. 1
0
        /// <summary>
        /// Parses WebDav_Response from 'DAV:response' element.
        /// </summary>
        /// <param name="reponseNode">The 'DAV:response' element</param>
        /// <returns>Returns DAV response.</returns>
        /// <exception cref="ArgumentNullException">Is raised when when <b>responseNode</b> is null reference.</exception>
        /// <exception cref="ParseException">Is raised when there are any parsing error.</exception>
        internal static WebDav_Response Parse(XmlNode reponseNode)
        {
            if (reponseNode == null)
            {
                throw new ArgumentNullException("responseNode");
            }

            // Invalid response.
            if (!string.Equals(reponseNode.NamespaceURI + reponseNode.LocalName, "DAV:response", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new ParseException("Invalid DAV:response value.");
            }

            WebDav_Response retVal = new WebDav_Response();

            foreach (XmlNode node in reponseNode.ChildNodes)
            {
                if (string.Equals(node.LocalName, "href", StringComparison.InvariantCultureIgnoreCase))
                {
                    retVal.m_HRef = node.ChildNodes[0].Value;
                }
                else if (string.Equals(node.LocalName, "propstat", StringComparison.InvariantCultureIgnoreCase))
                {
                    retVal.m_pPropStats.Add(WebDav_PropStat.Parse(node));
                }
            }

            return(retVal);
        }
Esempio n. 2
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", 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);
        }