예제 #1
0
        private XmlDocument getPublicAccountInformationXML()
        {
            var request = new GetPublicContainersInformationSerialized(CdnManagementUrl, Format.XML);
            var getSerializedResponse = _requestfactory.Submit(request, AuthToken);
            var xmlResponse = String.Join("", getSerializedResponse.ContentBody.ToArray());
            getSerializedResponse.Dispose();

            var xmlDocument = new XmlDocument();
            try
            {
                xmlDocument.LoadXml(xmlResponse);
            }
            catch (XmlException)
            {
                return xmlDocument;
            }

            return xmlDocument;
        }
예제 #2
0
        public XmlDocument GetPublicAccountInformationXML()
        {
            return StartProcess.ByLoggingMessage("Retrieving account information for account " + CdnManagementUrl)
                 .ThenDoing<XmlDocument>(() =>
                 {
                     var request = new GetPublicContainersInformationSerialized(CdnManagementUrl, Format.XML);
                     var getSerializedResponse = _requestfactory.Submit(request, AuthToken);
                     var xmlResponse = String.Join("", getSerializedResponse.ContentBody.ToArray());
                     getSerializedResponse.Dispose();

                     if (xmlResponse == null) return new XmlDocument();

                     var xmlDocument = new XmlDocument();
                     try
                     {
                         xmlDocument.LoadXml(xmlResponse);

                     }
                     catch (XmlException)
                     {
                         return xmlDocument;
                     }

                     return xmlDocument;
                 })
                 .AndIfErrorThrownIs<WebException>()
                 .Do((ex) =>
                 {
                     var response = (HttpWebResponse)ex.Response;
                     if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
                         throw new UnauthorizedAccessException("Your access credentials are invalid or have expired. ");
                     if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                         throw new PublicContainerNotFoundException("The specified container does not exist.");

                 })
                 .AndLogError("Failed to get account information for account " + CdnManagementUrl)
                 .Now();
        }
예제 #3
0
 private string getPublicAccountInformationJson()
 {
     var request = new GetPublicContainersInformationSerialized(CdnManagementUrl, Format.JSON);
     var getSerializedResponse = _requestfactory.Submit(request, AuthToken);
     return string.Join("", getSerializedResponse.ContentBody.ToArray());
 }