/// <summary>
 /// Initially used via a response callback for commands which expect a async response
 /// </summary>
 /// <param name="webResponse">the HttpWebResponse that will be sent back to the user from the request</param>
 protected override void ResponseCallback(HttpWebResponse webResponse)
 {
     // get the cloud service deployments
     IpAddressCheck             = Parse(webResponse, "AddressAvailabilityResponse", new AddressAvailabilityResponseParser(null));
     IpAddressCheck.RequestedIp = IPAddress.Parse(IpAddress);
     SitAndWait.Set();
 }
Пример #2
0
        internal override void Parse()
        {
            /*
             * <?xml version="1.0" encoding="utf-8"?>
             * <AddressAvailabilityResponse xmlns=”http://schemas.microsoft.com/windowsazure”>
             * <IsAvailable>indicator-of-availability</IsAvailable>
             * <AvailableAddresses>
             * <AvailableAddress>ip-address-1</AvailableAddress>
             * <AvailableAddress>ip-address-2</AvailableAddress>
             * <AvailableAddress>ip-address-3</AvailableAddress>
             * <AvailableAddress>ip-address-4</AvailableAddress>
             * <AvailableAddress>ip-address-5</AvailableAddress>
             * </AvailableAddresses>
             * </AddressAvailabilityResponse>*/
            var availability = new AvailableIpAddresses {
                AvailableIps = new List <IPAddress>()
            };
            var rootElement = Document.Element(GetSchema() + "AddressAvailabilityResponse");

            if (rootElement.Element(GetSchema() + "IsAvailable") != null)
            {
                availability.IpIsAvailable = bool.Parse(rootElement.Element(GetSchema() + "IsAvailable").Value);
            }
            if (!availability.IpIsAvailable)
            {
                foreach (XElement address in rootElement.Element(GetSchema() + "AvailableAddresses").Elements(GetSchema() + "AvailableAddress"))
                {
                    availability.AvailableIps.Add(IPAddress.Parse(address.Value));
                }
            }

            CommandResponse = availability;
        }
        private void UpdateAddresses()
        {
            AvailableIpAddresses.Clear();

            dataCenter.GetAllAvailableAddresses()
            .Select(address => address.Identifier.ToString())
            .Do(AvailableIpAddresses.Add);
        }
Пример #4
0
 public AddressAvailabilityResponseParser(XDocument response)
     : base(response)
 {
     CommandResponse = new AvailableIpAddresses();
 }