Example #1
0
        private WindowsStoreServiceAppNode WebRequestEndGetResponse(IAsyncResult asyncResult)
        {
            var request = (WebRequest)asyncResult.AsyncState;

            using (var response = (HttpWebResponse)request.EndGetResponse(asyncResult))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new WebException("Http Error: " + response.StatusCode);
                }

                using (var outputStream = response.GetResponseStream())
                {
                    using (var reader = XmlReader.Create(outputStream, new XmlReaderSettings {
                        IgnoreWhitespace = true, IgnoreComments = true
                    }))
                    {
                        return(WindowsStoreServiceAppNode.ParseXml(reader));
                    }
                }
            }
        }
        internal static WindowsStoreServiceAppNode ParseXml(XmlReader reader)
        {
            var node = new WindowsStoreServiceAppNode();

            reader.ReadStartElement();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                    case "Pt":
                        node.Package = WindowsStoreServiceAppPackageNode.ParseXml(reader);
                        break;

                    case "D":
                        node.Description = reader.ReadElementContentAsString();
                        break;

                    case "Dbps":
                        node.Features = reader.ReadElementContentAsArray(x => x.ReadElementContentAsString());
                        break;

                    case "Ud":
                        node.UpdateDescription = reader.ReadElementContentAsString();
                        break;

                    case "Bsl":
                        node.BaseLanguage = reader.ReadElementContentAsString();
                        break;

                    case "Sls":
                        node.SupportedLanguages = reader.ReadElementContentAsArray(x => x.ReadElementContentAsString());
                        break;

                    case "Dev":
                        node.DeveloperName = reader.ReadElementContentAsString();
                        break;

                    case "DevI":
                        node.DeveloperId = reader.ReadElementContentAsString();
                        break;

                    case "Cr":
                        node.Copyright = reader.ReadElementContentAsString();
                        break;

                    case "Ws":
                        node.Website = reader.ReadElementContentAsString();
                        break;

                    case "Sws":
                        node.SupportWebsite = reader.ReadElementContentAsString();
                        break;

                    case "Pu":
                        node.PrivacyPolicyWebsite = reader.ReadElementContentAsString();
                        break;

                    case "Eula":
                        node.EndUserLicenseAgreement = reader.ReadElementContentAsString();
                        break;

                    case "Sas2":
                        node.SupportedArchitectures = reader.ReadElementContentAsArray(WindowsStoreServiceAppArchitectureNode.ParseXml);
                        break;

                    case "Sss":
                        node.Screenshots = reader.ReadElementContentAsArray(WindowsStoreServiceAppScreenshotNode.ParseXml);
                        break;

                    default:
                        reader.Skip();
                        break;
                }
            }

            reader.ReadEndElement();

            return node;
        }
        internal static WindowsStoreServiceAppNode ParseXml(XmlReader reader)
        {
            var node = new WindowsStoreServiceAppNode();

            reader.ReadStartElement();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                case "Pt":
                    node.Package = WindowsStoreServiceAppPackageNode.ParseXml(reader);
                    break;

                case "D":
                    node.Description = reader.ReadElementContentAsString();
                    break;

                case "Dbps":
                    node.Features = reader.ReadElementContentAsArray(x => x.ReadElementContentAsString());
                    break;

                case "Ud":
                    node.UpdateDescription = reader.ReadElementContentAsString();
                    break;

                case "Bsl":
                    node.BaseLanguage = reader.ReadElementContentAsString();
                    break;

                case "Sls":
                    node.SupportedLanguages = reader.ReadElementContentAsArray(x => x.ReadElementContentAsString());
                    break;

                case "Dev":
                    node.DeveloperName = reader.ReadElementContentAsString();
                    break;

                case "DevI":
                    node.DeveloperId = reader.ReadElementContentAsString();
                    break;

                case "Cr":
                    node.Copyright = reader.ReadElementContentAsString();
                    break;

                case "Ws":
                    node.Website = reader.ReadElementContentAsString();
                    break;

                case "Sws":
                    node.SupportWebsite = reader.ReadElementContentAsString();
                    break;

                case "Pu":
                    node.PrivacyPolicyWebsite = reader.ReadElementContentAsString();
                    break;

                case "Eula":
                    node.EndUserLicenseAgreement = reader.ReadElementContentAsString();
                    break;

                case "Sas2":
                    node.SupportedArchitectures = reader.ReadElementContentAsArray(WindowsStoreServiceAppArchitectureNode.ParseXml);
                    break;

                case "Sss":
                    node.Screenshots = reader.ReadElementContentAsArray(WindowsStoreServiceAppScreenshotNode.ParseXml);
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            reader.ReadEndElement();

            return(node);
        }